I'm trying to parse a single string and get multiple chunks of data out from the same string with the same regex conditions. I'm parsing a single HTML doc that is static (For an undisclosed reason, I can't use an HTML parser to do the job.) I have an expression that looks like:
$string =~ /\<img\ssrc\="(.*)"/;
and I want to get the v...
How do you match more than one pattern in vbscript?
Set regEx = New RegExp
regEx.Pattern = "[?&]cat=[\w-]+" & "[?&]subcat=[\w-]+" // tried this
regEx.Pattern = "([?&]cat=[\w-]+)([?&]subcat=[\w-]+)" // and this
param = regEx.Replace(param, "")
I want to replace any parameter called cat or subcat in a string called param with nothing....
I found the answer to this, but it's a bit of a gotcha so I wanted to share it here.
I have a regular expression that validates passwords. They should be 7 to 60 characters with at least one numeric and one alpha character. Pretty standard. I used positive lookaheads (the (?= operator) to implement it:
(?=^.{7,60}$)(?=.*[0-9].*)(?=.*[a...
Good Day,
I have tried, and burned my brain to understand the definition of Regular Languages in Discrete Mathematics and its Applications(Rosen) without reaching the goal of understanding why the definition is like that in this book. On page(789), I am rephrasing the definition:
Type 3 grammars are defined as:
w1 --> w2
Where w1 is...
What's the best regular expression for integer separated by comma? It can also contain space between comma, and the field is not required which means it could be blank.
123,98549
43446
etc..
...
I'm trying to extract "Florida (FL)" from http://www.auctionarms.com/search/displayitem.cfm?itemnum=9736364&oh=216543.
My code is
//get location
$pattern = "/(State)<\/i>\:<\/td>(.*)<\/td>/";
preg_match_all($pattern, $htmlContent, $matches);
print_r($matches);
any idea why is not working ?
...
Consider this javascript:
var values = {
name: "Joe Smith",
location: {
city: "Los Angeles",
state: "California"
}
}
var string = "{name} is currently in {location.city}, {location.state}";
var out = string.replace(/{([\w\.]+)}/g, function(wholematch,firstmatch) {
return typeof values[firstmatch] !== 'u...
I'm using grep to filter the Mac OS X dictionary words file (by default located at /usr/share/dict/words).
I want to use grep to retrieve all words four characters long. How do I do this?
My best guess for how to do this was:
grep [:alpha:]{4} words
But that returns zero results.
...
Hi, which structure returns faster result and/or less taxing on the host server, flat file or database (mysql)?
Assume many users (100 users) are simultaneously query the file/db.
Searches involve pattern matching against a static file/db.
File has 50,000 unique lines (same data type).
There could be many matches.
There is no writing to...
I'm writing a script to add extra smileys to the Gmail chat.
Its working partially, i'm stuck with the innerHTML.replace method @line 33
If you see, the regex in the replace method is passed using a variable. This is where the script is choking.
If i replace the variable with the actual regex, it works fine :|
...
Got this function for ammending the query string and was wondering what the replacement part of the pre_replace meant (ie- $1$2$4).
function add_querystring_var($url, $key, $value) {
$url = preg_replace('/(.*)(\?|&)' . $key . '=[^&]+?(&)(.*)/i', '$1$2$4', $url . '&');
$url = substr($url, 0, -1);
if (strpos($url, '?') === false) {
...
I have this regular expression:
([http://some.url.com/index.php?showtopic=\"]*)([0-9]+(?:\.[0-9]*)?)
its for extracting links to topics from forum
Now when i use it in my script
$url = "([http://some.url.com/index.php?showtopic=\"]*)([0-9]+(?:\.[0-9]*)?)";
preg_match_all spits: "Unknown modifier '('"
This is also the call to preg...
I'm trying to create a regex that matches the inverse of a certain string type (so, strings not ending in ".js", for example).
According to the documentation, that should be the expression #rx"(?!\\.js$)", but it doesn't seem to work. To test it out, I have this function:
(define (match-test regex)
(map (lambda (text)
(...
I have the following string:
"h3. My Title Goes Here"
I basically want to remove the first 4 characters from the string so that I just get back:
"My Title Goes Here".
The thing is I am iterating over an array of strings and not all have the h3. part in front so I can't just ditch the first 4 characters blindly.
I have checke...
So, I have an RSS feed with variations of each item. What I want to do is just get entries that contain a specific section of text.
For example:
<item>
<title>RADIO SHOW - CF64K - 05-20-10 + WRAPUP </title>
<link>http://linktoradioshow.com</link>
<comments>Radio show from 05-20-10</comments>
<pubDate>Thu, 20 May 2010 1...
In Java, and it seems in a few other languages, backreferences in the pattern is preceded by a slash (e.g. \1, \2, \3, etc), but in a replacement string it's preceded by a dollar sign (e.g. $1, $2, $3, and also $0).
Here's a snippet to illustrate:
System.out.println(
"left-right".replaceAll("(.*)-(.*)", "\\2-\\1") // WRONG!!!
); //...
There are so many questions on regex-negation here on SO.
I am not sure I understand why people feel the need to negate a regex.
Why not use something like grep -v that shows only the results that do not match the regex?
$ ls
april august december february january july june march may november october september
$ ls | grep...
My Friends,
I really want to extract a simple IP address from a string (actually an one-line html) using Python. But it turns out that 2 hours passed I still couldn't come up with a good solution.
>>> s = "<html><head><title>Current IP Check</title></head><body>Current IP Address: 165.91.15.131</body></html>"
-- '165.91.15.131' is w...
I'm having hard time getting my head wrapped around this one - and it should be trivial.
I would like to redirect one URL with a specific query string to another URL.
I want to send any requests that contain the query string in the URL
http://example.com/index.php?option=com_user&view=register
To:
http://example.com/index.php?o...
Hello everyone.
I'm trying to redirect an easy to remember url to a php file but I'm having some trouble with the regex.
Here's what I have at the moment:
RewriteRule ^tcb/([a-zA-Z0-9]{1,})/([a-zA-Z0-9]{1,})/([a-zA-Z0-9]{1,}) /tcb/lerbd.php?autocarro=$1&tipo=$2&dsd=$3
It is working but only if I supply all 3 arguments. I want the la...