I'm very poor with regexps but this should be very simple for someone who knows regexps.
Basically I will have a string like this:
<if>abc <else>xyz
I would like a regexp so if the string contains <if> <else>, it splits the string into two parts and returns the two strings after <if> and <else>. In the above example it might return a...
I have in the settings file a row of all the file types I want to allow:
jpeg|jpg|tiff|tif|png|gif|bmp|eps|wmf|emf|pdf|doc|docx|zip|rar|ppt|pptx|mdb|xls
I want to have next to the FileUpload control a RegularExpressionValidator that allows only these files.
I am handling it in the PageLoad event setting the ValidationExpression prope...
I have a string like this:
Heading
Some interesting text here
HeadingSome interesting text hereHeading
Some interesting text here
Heading
Some interesting text here
What I want to do, is to add another heading under the third heading so it would end up looking like this:
Heading
Some interesting text here
HeadingSome interesting text...
Hi,
I have a string which contains the text of an article. This is sprinkled with BBCodes (between square brackets). I need to be able to grab the first say, 200 characters of an article without cutting it off in the middle of a bbcode. So I need an index where it is safe to cut it off. This will give me the article summary.
The summa...
I have music file names like:
Gorillaz (2001)
Gorillaz (7th State Mix) (2002)
Gorillaz (2001) (Featuring Travis)
Gorillaz (1Mix) (2003)
Gorillaz (1000) (2001)
How do I parse the year in the cleanest, easiest way?
Right now I am parsing them by finding each '(' and then making sure the character count between the ()s are 4 and first c...
Hello,
I would like to know how this can be achieved.
Assume: That there's a lot of html code containing tables, divs, images, etc.
Problem: How can I get matches of all occurances. More over, to be specific, how can I get the img tag source (src = ?).
example:
<img src="http://example.com/g.jpg" alt="" />
How can I print out ht...
I've got a string that I'm trying to split into chunks based on blank lines.
Given a string s, I thought I could do this:
re.split('(?m)^\s*$', s)
This works in some cases:
>>> s = 'foo\nbar\n \nbaz'
>>> re.split('(?m)^\s*$', s)
['foo\nbar\n', '\nbaz']
But it doesn't work if the line is completely empty:
>>> s = 'foo\nbar\n\nbaz'...
Hey guys, I'm trying to select a specific string out of a text, but I'm not a master of regular expressions.
I tried one way, and it starts from the string I want but it matches everything after what I want too.
My regex:
\nSCR((?s).*)(GI|SI)(.*?)\n
Text I'm matching on.
Hierbij een test
SCR
S09
/[email protected]
05FEB
GI BRGDS OPS
m...
I need to find a regular expression that would be able to work around an issue I am having.
Query: barfly london
Should match: Camden Barfly, 49 Chalk Farm Road, London, NW1 8AN
I've tried many, many regex's for this, but none have worked so far. I am considering that maybe I will need to split the search into two separate qu...
Someone is telling me I need to escape a semicolon in a Perl regular expression literal. That is, to match a line containing a semicolon, I should use /\;/ and not /;/.
From what I've read, the semicolon has no special meaning in a regular expression literal, so escaping it seems unnecessary. I've done some experiments and /;/ seems to ...
Got a simple task to get a XPath expression and return a prefix that matches the parent of the node that (might be) selected.
Example:
/aaa/bbb => /aaa
/aaa/bbb/ccc => /aaa/bbb
/aaa/bbb/ccc[@x='1' and @y="/aaa[name='z']"] => /aaa/bbb
Because the patterns inside the square brackets might contain brackets within quotes, I d...
I have a solution for my question, but I'm trying to get better at regex especially in javascript. I just wanted to bring this to the community to see if I could write this in a better way.
So, I get a datetime string that comes from .net and I need to extract the date from it.
Currently what I have is:
var time = "2009-07-05T00:00:00...
How should I parse the following String using Java to extract the file path?
? stands for any number of random charaters
_ stands for any number of white spaces (no new line)
?[LoadFile]_file_=_"foo/bar/baz.xml"?
Example:
10:52:21.212 [LoadFile] file = "foo/bar/baz.xml"
should extract foo/bar/baz.xml
...
Hi, I've been trying to do the following:
if (m/(foobar)\{2,}?/ig)
to process a file and only act on those lines where greater than 2 occurences of 'foobar' are present. Not working - I suspect it may need the "back-referencing" technique, but I'll be pleasantly surprised if someone here can do it with a simple matching technique
...
i am building a system for automatically parsing incoming emails and populating a database from them
initially there will only be 10-20 expected formats coming in, but long term there is the possibility of thousands of different formats
the way i see it
i need to identify format of email (eg regex on subject line)
parse the email wi...
I'm trying to use python's re.sub function to replace some text.
>>> import re
>>> text = "<hi type=\"italic\"> the></hi>"
>>> pat_error = re.compile(">(\s*\w*)*>")
>>> pat_error.search(text)
<_sre.SRE_Match object at 0xb7a3fea0>
>>> re.sub(pat_error, ">\1", text)
'<hi type="italic">\x01</hi>'
Afterwards the value of text should be
...
I'm trying to extract the first user-right from semicolon separated string which matches a pattern.
Users rights are stored in format:
LAA;LA_1;LA_2;LE_3;
String is empty if user does not have any rights.
My best solution so far is to use the following regex in regex.replace statement:
.*?;(LA_[^;]*)?.*
(The question mark at th...
The page: /index.php?page=6&test=1&test2=2
The code below strip's page=6 off of this so I can add our new page to the url and add the $url_without_page_var back to our link again:
$_SERVER['argv'][0]
// Displays: page=6&test=1&test2=2
And
$url_without_page_var=preg_replace('/page=(\d+)/i','',$_SERVER['argv'][0]);
// Displays: &te...
Hello. I am trying to extract information from a tags using a regex, then return a result based on various parts of the tag.
preg_replace('/<(example )?(example2)+ \/>/', analyze(array($0, $1, $2)), $src);
So I'm grabbing parts and passing it to the analyze() function. Once there, I want to do work based on the parts themselves:
funct...
When i use the command above, i get wrong matches.....can someone explain me, what is wrong?
I'm trying to search for the string "..." in all files in the current folder.
...