I am trying to use an HTML form and javascript (i mention this, because some advanced features of regex processing are not available when using it on javascript) to acomplish the ... |
I'm trying to do a replace on the following string prototype: "I‘m singing & dancing in the rain." The following regular expression matches the instance properly, but also captures the character ... |
Ideally, I'd like to capture foo.com from something like http://foo.com/bar?param=value or https://www.foo.com
Thanks.
Edit: Sorry for the vagueness. I'll be doing this in Javascript.
2nd Edit: I should post ... |
The problem: I'm trying to style certain keywords (e.g. "function") within the content of a code-tag, excluding those keywords from the C-style comments that appear in that content.
Solution: I believe ... |
x = "abcdefg"
x = x.match(/ab(?:cd)ef/)
shouldn't x be abef? it is not, it is actually abcdef
Why is it that my ?: not having any effect? (of course my understanding could very well ... |
I am using the following regex:
(public|private +)?function +([a-zA-Z_$][0-9a-zA-Z_$]*) *\\(([0-9a-zA-Z_$, ]*)\\) *{(.*)}
To match the following string:
public function messenger(text){
sendMsg(text);
}
private function sendMsg(text){
alert(text);
}
(There is no line breaks in the string, they are converted to whitespaces ... |
I have got the following regular expression working just fine in Rad Software Regular Expression designer.
param\s+name\s*=\s*"movie"\s+value=\s*"(?<target>.*?)"
And now I am wondering, how to get this to work in JavaScript. It keeps on ... |
|
I am trying to capture "Rio Grande Do Leste" from:
...
<h1>Rio Grande Do Leste<br />
...
using
var myregexp = /<h1>()<br/;
var nomeAldeiaDoAtaque = myregexp.exec(document);
what am I doing wrong?
update:
2 questions remain:
1) searching (document) didn“t produce ... |
I have ref=Apple
and my current regex is
var regex = /ref=(.+)/;
var ref = regex.exec(window.location.href);
alert(ref[0]);
but that includes the ref=
now, I ... |
So I am trying to create a Javascript Regex that captures the filename without the file extension. I have read the other posts here and 'goto this page: |
Is there anyway I can find the index (in string) of my RegExp capture? eg ...
var str = "hello world";
var regex = /lo (wo)/;
var match = regex.exec(str);
// what I want is ...
|
i need a regular expression to capture a given URLs SLD.
Examples:
jack.bop.com -> bop
bop.com -> bop
bop.de -> bop
bop.co.uk -> bop
bop.com.br -> bop
All bops :). So this regex needs to ignore ccTLDs, gTLDs ... |
re = /\s{1,}(male)\.$/gi
"A girl is a female, and a boy is a male.".match(re);
this results in " male."
what i want is "male"
I put male in parenthesis and I though that would capture ... |
As far as I know there is no such thing as named capturing groups in JavaScript. What is the alternative way to get similar functionality?
|
I have a url string from which I want to capture all the words between the / delimiter:
So given this url:
"/way/items/add_items/sell_items":
I want to capture:
way
items
sell_items
add_items
If I do it like this:
'/way/items/sell_items/add_items'.match(/(\w+)/g)
=> [ 'way', ...
|
I have this paragraph:
<p>FIRST SECOND THIRD</p>
and I want to wrap the second word in a SPAN like so:
<p>FIRST <span>SECOND</span> THIRD</p>
If I do this:
text.replace(/\s(\w+)\s/, '<span>$1</span>');
the space characters before and after the ... |
I am trying to do some string replacement with RegEx in Javascript. The scenario is a single line string containing long comma-delimited list of numbers, in which duplicates are possible.
An ... |
I'd like to know how to replace a capture group with its uppercase in JavaScript. Here's a simplified version of what I've tried so far that's not working:
> a="foobar"
'foobar'
> a.replace( /(f)/, ...
|
I am exploring capturing groups in Regex and I am getting confused about lack of documentation on it. For ex, can anyone tell me difference between two regex:
/(?:madhur)?/
and
/(madhur)?/
As per me, ? ... |
Possible Duplicate:
regex to find url in a text
Can I get a regular expression that will capture every URL from a string, I'd like to ... |
ok, I guess the code says it all.
//I have this string.
var str = '"Watch out" "for the" "rock!"'
//this is one of the many patterns that I tried
res=str.match(/"(.*)" "(.*)" "(.*)"/g)
I want an ... |
I'm a bit rusty on my regex and javascript. I have the following string var:
var subject = "javascript:loadNewsItemWithIndex(5, null);";
I want to extract 5 using a regex. This is my regex:
/(?:loadNewsItemWithIndex\()[0-9]+/)
Applied like ... |
Noticed a difference between what Rubular.com and Javascript regexes:
'catdogdogcatdog'.match(/cat(dog)/g); // JS returns ['catdog', 'catdog']
I expected to capture 'dog' twice but instead I get 'catdog' twice.
Rubular captures 'dog' twice ... |
As I am reading through someone else's JavaScript, I encountered this regex charset:
[\0-\uffff]
What exactly is captured by this?
|
Strange one here (or maybe not), I am attempting to retrieve two capturing groups via Javascript regex, first group: one or more digits (0-9), second group: one or more word characters ... |