|
I use Regexp::Assemble in my project, but I don't understand why this little sample doesn't work:
#!/usr/bin/perl use strict; use warnings; use Regexp::Assemble; my $re1 = "(run (?:pre|post)flight script for .+)"; my $re2 = "((?:Configu|Prepa)ring volume...
Started by sebthebert on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Int the trailing .+ common to all patterns not being factored into one occurence in the regexp.
|
|
I have this:
var regExp:RegExp = new RegExp("((.*?)%)");
and want everything between the ( and the %) the string looks like this: (-24%)
I now get a return back "(-24" and have searched for a long time to find a solution but didn't find any.
Started by arno on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Alternatively you could.
You need to escape the parentheses
use:
var regExp:RegExp = new RegExp("\\((.*?)%\\)");
for example with lookahead, lookbehind if you need to find what's inside something with a regexp.
|
|
How can I search for a » character in a JavaScript regexp?
Code that's not working right now:
var extralinks = new RegExp('»','g'); div.innerHTML = div.innerHTML.replace(extralinks,'This is special punctuation');
Grazie!
Started by Summer on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Look up the ASCII table and escape the character http://www.asciitable.com/ var extraLinks = /\xBB/g; .
|
Ask your Facebook Friends
|
Basically, my question is about how Javascript handles regex literals.
Contrasting with number, string and boolean where literals are primitive data types and corresponding Number, String and Boolean objects exist with seamless type conversion, are regex...
Started by Crimson on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Yes, new RegExp("something", "g") is the same as /something/g
Yes, the following two expressions are equivalent:
var r1 = /ab+c/i, r2 =new RegExp("ab+c", "i");
The constructor property of both the first time the literal is....
|
|
Hey,
Im trying to use regexp to get whatever's behind the # in my string "12344dfdfsss#isa", in this case I wanna get the 'isa' out of the string.
I found these answers (http://stackoverflow.com/questions/578821/how-to-remove-a-small-part-of-the-string...
Started by meow on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Try this:
var trimmed = /#(.*)$/.exec('12344dfdfsss#isa')[1];
You can use also use match to match a string against a regex, and then extract the first subexpression that matched using [1] :
var trimmed = '12344dfdfsss#isa'.match(/#(.*)$/)[1]
if it's... .
|
|
A cut down version of my code sort of looks like this:
string="test test testtest testtest test"; replacer="test"; string=string.replace(new RegExp(' '+replacer+' ','gi')," REPLACED ");
Now, I want to replace a word only if there's a space surrounding...
Started by Dean on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
You probably want this:
string=string.replace(new RegExp('\\b'+replacer+'\\b','gi'),"REPLACED this:
string=string.replace(new RegExp('(\\s)'+replacer+'(\\s)','gi'),"$1REPLACED$2");
Why don't you try this:
RegExp....
With spaces.
|
|
It's my understanding that all three of these lines below should return an ARRAY with 2 results in it. Yet RegExp will only return 1 result no matter how many times the regex repeats in the string.
Can some one explain why? And perhaps suggest how I can...
Started by STHayden on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
On subsequent calls:
>>> var v = /new york/gi >>> v.exec("NEW YORK new york") ["NEW YORK"] >>> v.exec("NEW YORK new york") ["new york"] >>> v.exec("NEW YORK ....
|
|
Hi there,
I have some code for validating date below:
function validateForm() { var errFound = 0; //var patt_date = new RegExp("^((((19|20)(([02468][048])|([13579][26]))-02-29))|((20[0-9][0-9])|(19[0-9][0-9]))-((((0[1-9])|(1[0-2]))-((0[1-9])|(1\d)|(2[...
Started by Dels on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
I would suggest this procedure instead:
Check date against regexp.
Of what regexps were designed for.
|
|
There is no default RegEx library on the iPhone. Is it ok if I use UIWebView's stringByEvaluatingJavaScriptFromString to evaluate a JavaScript string that actually uses the RegExp object to evaluate an expression? Is this supported on the iPhone?
Started by luvieere on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
StringByEvaluatingJavaScriptFromString: @"re = new RegExp('su{1,3}p+er'); re.test('suuuper')"]);
Javascript-compliant Regular Expressions, leading to reuse and portability of existent JS Regexp code you.
|
|
Hi!
I try to write a simple Markdown parser in JavaScript. Therefore I want to check for the [link content][link id] syntax. I use the following code:
data = data.replace( /\[(.*?)\][ ]*\[([0-9]+)\]/g, '<a href="$2">$1</a>' );
It works well...
Started by okoman on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
To escape the backslashes, since you want literal backslashes in the pattern:
var r = new RegExp;a href="$2">$1</a>' );
Double escape you backslashes:
var r = new RegExp( '\\[(.*?)\\][ ]*\[([0-9]+)\\]', 'g' );
You....
|