I'm using Python to write a regular expression for replacing parts of the string with a XML node.
The source string looks like:
Hello
REPLACE(str1) this is to replace
REPLACE(str2) this is to replace
And the result string should be like:
Hello
<replace name="str1"> this is to replace </replace>
<replace name="str2"> this is to rep...
I'm looking for a regular expression to remove a single parameter from a query string, and I want to do it in a single regular expression if possible.
Say I want to remove the foo parameter. Right now I use this:
/&?foo\=[^&]+/
That works as long as foo is not the first parameter in the query string. If it is, then my new query stri...
hi all,
here's my string:
</HEAD>
<BODY>
<html>
<head>
i need to detect the line-breaks so i used [\r\n]+
but the problem is, i need it to be optional - like the filter rule should also work if there are no line breaks at all (between rbody + html) .. how would i do that?
thx
...
A string must not include spaces or special characters. Only a-z, A-Z, 0-9, the underscore, and the period characters are allowed.
How do I achieve this?
Update:
All the solutions posted worked for me.
Thanks everyone for helping out.
...
Hi,
Thanks for taking the time out to read.
I have a folder of MP3 files, that I want to use PHP to get the Artist and Title out, as the ID3 tags are non existent.
An example:
01. Wham - Last Christmas.mp3
02. Mariah Carey - All I Want For Christmas Is You.mp3
03. Band Aid - Do They Know It's Christmas Time.mp3
I am sure it's poss...
I'm reading Douglas Crockfords Javascript: The Good Parts, I just finished the regular expressions chapter. In this chapter he calls javascript's \b, positive lookahead (?=) and negative lookahead (?!) "not a good part"
He explains the reason for \b being not good (it uses \w for word boundary finding, and \w fails for any language that...
I found all sorts of really close answers already, but not quite.
I need to look at a string, and find any character that is used more than 3 times. Basically to limit a password to disallow "mississippi" as it has more than 3 s's in it. I think it only needs to be characters, but should be unicode. So I guess the (:alpha:) for the c...
Hey all, I've got the following regex:
var outstring = inputsplit.join(';').replace(/\s/g, '');
the problem is, given the array:
["this ", "is ", "a ", "test"]
the output is
"this;is ;a ;test"
instead of
"this;is;a;test"
any pointers on what I can do to get this global filter to work?
...
Im handling various email addresses that come in the following forms
John Doe <[email protected]>
[email protected]
How could i use regex, to find the @ symbol, and then return the integer's behind it (until it doesnt find anymore, or runs into a non number, < or space for example.)
...
When I searched about something, I found an answered question in this site. 2 of the answers contain
/([^.]*)\.(.*)/
on their answer.
The question is located at http://stackoverflow.com/questions/233922/find-replace-jquery. I'm newbie in javascript, so I wonder, what does it mean? Thanks.
...
Several times recently I've wanted to create a regular expression that will never match any input (even an empty string). Some of the apparently most obvious ways are either very crude, turn out to have undesirable behaviour... or just plain don't work!
My provisional solution, which works fine for my particular case is simply a patter...
Hi,
I have created one regular expression which is supposed to match for line starting with Project followed by either # or : or - followed by 1 to 3 digit number or simply Title.
For example, following lines should get matched
Project # 1
Project#1
Project :1
Project-123
Project Title
but following should not match
Project AB...
I would require a RegEx in .NET in such a way that to remove the commented lines in HTML page/code where ever the tag finds as commented portion or code.
For reference:
<!--loop output-------end-->
I want to remove the portion of commented code/line as above using RegEx.
Provide me a RegEx for the same.
...
I have data like this:
# data_display
ab as we hj kl
12 34 45 83 21
45 56 98 45 09
I need just the first column alone, and only the rows starting with numbers.
I now use:
# data_display | awk '{ print $1 }' | grep "^[0-9]"
Is there any way to optimise it more, like using the regex in awk itself?
I am very new to awk.
Tha...
Hello,
I have weather forecast data formatted like so:
loc_id#location#state#forecast_date#issue_date#issue_time#min_0#max_0#min_1#max_1#min_2#max_2#min_3#max_3#min_4#max_4#min_5#max_5#min_6#max_6#min_7#max_7#forecast_0#forecast_1#forecast_2#forecast_3#forecast_4#forecast_5#forecast_6#forecast_7#
090180#Airey's Inlet#VIC#20091204#20091...
Hello,
I need to parse a search query with a "Google-like" syntax (but simpler, since I don't need parenthesis, operator nesting and such). An example string might be:
TAG1: a,b,c TAG2: 123 TAG3: a,45,44,b
So, simply put, I need to recognize tokens which look like a TAG (i.e "color", "name", "age") followed by : and by a single "word"...
I do not know where my head is today, can somebody please explain to me - why I can get the hturl value by the request form and do the replace in the htstring? (I do this and it works - but only replaces one occurance of the (hturl) value.... The problem is that there is about 10 more occurances of the old value that I want to replace:
...
i need to format mobile numbers.
e.g.
+61421 123 123
0421 123 123
0061421123123
0421 123123
1) into this type of string to save in the dbf
0421123123
2) then display it in this format
0421 123 123
any suggestion on the most effective way to format the numbers?
...
Hi
I have a database table with around 1000 keywords/phrases (one to four words long) - This table changes rarely, so I could extract the data into something more useful (like a regular expression?) - So this is not finding / guessing at keywords based on natural language processing..
I then have a user inputting some text into a form ...
Hi all,
I'm using this code
$patterns = "!((http:/{2}[\w\.]{2,}[/\w\-\.\?\&\=\#]*)|(www\.[/\w\-\.\?\&\=\#]*)|([a-zA-Z0-9-\.]+(com|us|co.il)[^\s]*))!e";
return preg_replace($patterns, "'<a class=\"highlight boughtAt\" href=\"\\1\" title=\"\\1\" target=\"_blank\">'.(strlen('\\1')>=$chr_limit ? substr('\\1',0,$chr_limit).'$add':'\\1').'<...