I'm banging my head against a wall. I want a regex that matches: empty string, A, AB, and ABC, but not AC. I have this, which works:
/^(A|AB|ABC)?$/
But this is a simplification; in my app A, B, and C are actually long character classes, so I don't want to repeat them over and over. Maybe I'm just not looking at it the right way. I tr...
I'm trying to find a regex that works to match a string of escape characters (an Expect response, see this question) and a six digit number (with alpha-numeric first character).
Here's the whole string I need to identify:
\r\n\u001b[1;14HX76196
Ultimately I need to extract the string:
X76196
Here's what I have already:
interact...
I want to get the xpath count of all the divs/links/.. that have text matching some regular expression. For example:
<span> day 2 night </span>
<span> day 4 night </span>
<span> day 17 night</span>
I would like to be able to call:
sel.get_xpath_count('regexp:day \d night')
and have it return 2. (This is a simple example of course, ...
Greetings, I have file with the following strings:
string.Format("{0},{1}", "Having \"Two\" On The Same Line".Localize(), "Is Tricky For regex".Localize());
my goal is to get a match set with the two strings:
Having \"Two\" On The Same Line
Is Tricky For regex
My current regex looks like this:
private Regex CSharpShortRegex = new...
Let's say I have a string that can contain any UTF-16 characters, but I want to replace all characters not in a whitelist with an underscore. Let's say the whitelist is [A-Za-z], [0-9], and [-:.].
How would I use the Regex class to replace all characters not in the whitelist?
...
I'm using cURL to grab a page and I want to parse out the title of the post (the actual text shown on the link, not the title attribute of the <a>).
The HTML is like this:
<li class="topic">
<a title="Permanent Link to Blog Post" rel="bookmark" href="http://www.website.com/blog-post/">Title of blog post</a>
</li>
I tried using...
I am trying to insert line break tags into some text and displaying it on a web page. The < and > signs are being translated into < and > and the tags are showing up as text on the web page.
The text looks like this when I select it from the database (I've output it to SYSOUT):
version 12.4
service timestamps debug datetime
ser...
What would be a regular expression which I can use to match a valid JavaScript function name...
E.g. myfunction would be valid but my<\fun\>ction would be invalid.
[a-zA-Z0-9_])?
...
Hi, I have page designed in Django that has its own search engine. What I need help with is construction of regex that will filter only valid queries, which are consisting only of polish alphabet letters(both upper- and lowercase) and symbols * and ? , can anyone be of assistance?
EDIT:
I tried something like that:
query_re = re.compil...
I have this regex. My problem is the two second lines of the code:
<%
content = ""+Request.Form("completehtml")+"";
contentmatch = content;
contentmatch = content.match(/<div class="content">[\s\S]+?#-#/ig);
htstring1 = contentmatch;
htstring2 = htstring1.replace(/#-#/ig, '');
%>
I want to match something and then after everything ...
Consider:
<%
content = ""+Request.Form("completehtml")+"";
contentmatch = content;
contentmatch = contentmatch.match(/(<div class="content">[\s\S]+?)(?=[##])/ig);
%>
If I get the above match and it gives me some HTML: is it possible to find text in the match and to replace it again?
contentmatch ...
I'm trying to match on "url" BB code tag in a random piece of text. Example text:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. [url]http://www.google.com[/url] Donec purus nunc, rhoncus vitae tempus vitae, [url=www.facebook.com]facebook[/url] elementum sit amet justo.
I want to find both "url" tags from this text:
[u...
How can I replace this:
lyrics = lyrics.gsub(/\n/,'').gsub(/^\{\"similar\": \[/, '').gsub(/\]\}$/, '').gsub(/^\{/, '').gsub(/\}$/, '')
to something shorter and one gsub call?
...
Pre-scriptum: I'm purely curious, and am aware of other perfectly suitable solutions to this, that lie outside the domain of regular expressions.
How do I match from a beginning tag, and until a closing tag with possible nested, and perhaps identical tags. So say I have given in an HTML file:
<div class="nice">
<a href="http://www....
Multiline Test string:
dkdkdkdk dkdkdkdk dkdkdkd dkdkdkd "hello" dkdkdkdkdk dkdkdk "goodbye.hello" dkdkdkd kdkdkd kdkdkdk "hello.goodbye.hello" dddd "test" ssss "http:x-y.f/z/z" "" "."
"http:/dkdkd/dkdkdk/dkdkdkdkdkdk.g"
I want to match every quoted string that contains "hello"
This matches every quoted string
\"(.+?)\"
This matc...
I have the following regular expression, that I am compiling with Pattern class.
\bIntegrated\s+Health\s+System\s+\(IHS\)\b
Why is this not matching this string?
"test pattern case Integrated Health System (IHS)."
If I try \bpattern\b, it seems to work, but for the above phrase it does not. I have the parenthesis in the pattern esc...
I want to match a sequence of Rapidshare links on a webpage. The links look like:
http://rapidshare.com/files/326251387/file_name.rar
I wrote this code:
if(preg_match_all('/http:\/\/\rapidshare\.com\/files\/.*?\/.*?/', $links[1], $links))
{
echo 'Found links.';
} else {
die('Cannot find links :(');
}
And it retuns Cannot fi...
Hi,
I am looking for a Java regexp lib with support for recursion, like:
"<a+(?0)>"
JDK does not support it, ORO does neither.
Anyone knows about such?
Thanks,
Ondra
Edit: See http://www.php.net/manual/en/regexp.reference.recursive.php
And I need it for this expression:
(?:mUi)^/--++ *+(.*)(?: *(?<= |^)\\.((?:\\([^)\\n]+\\)|\\[[...
I have a string that looks like:
http://www.example.com/index.do/blah/1_44/asdf/asdf/asdf
http://www.example.com/index.do/blah/1_44_2342/asdf/asdf/asdf
I need to grab the value 44 from the above, ofcourse '44' could be any number.
The number '44' always is prefixed with a _, and after it could be another _ or /.
I have no idea of the...
I am trying to match any or all from a set of phrases in a given string. Here is my regex:
(^|\\W)(" + phrase1 + "|" + phrase2 + "|" + phrase3 + ... ")(\\W|$)
I need to be able to match any number of the phrases I am ORing. It seems to work okay except when two phrases occur immediately next to each other. So "phrase1 lorem ipsum phra...