im trying to learn about regex, and how to use it braking up som logs and populating som textboxes with the results.
if i have a simple line like this
Port status: tro-S-02-av1 0/23
and want to put the tro-S-02-av1 and the 0/23 in a variable
all names wold end on av1 so the regular exspression shold be based on this.
i was thinking ...
Hey guys,
there are lots of scripts out there to trim a string in javascript, but none how to Left Trim String.
This is what I use to trim:
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g,"");
}
But I would like to change this a little and create a new function called leftTrim that only removes the leading s...
I have, for example, markup like this
<div id="content">
<p>Here is some wonderful text, and here is a <a href="#">link</a>. All links should have a `href` attribute.</p>
</div>
Now I want to be able to perform some regex replace on the text inside the p element, but not in any HTML, i.e. be able to match the href within backticks...
I have a requirement to parse the content out of Dreamweaver templates.
I'm using C#.
Here is some example content that I will need to parse.
<div id="myDiv">
<h1><!-- InstanceBeginEditable name="PageHeading" -->
The Heading<!-- InstanceEndEditable --></h1>
<!-- InstanceBeginEditable name="PageContent" -->
<p>
Lorem...
When I test my javascript at this site it behaves as I would expect.
However when I try and test it on my page it ALWAYS fails the test
function testName() {
if (new RegExp('^(?!^(\..+)?$)[^\x00-\x1f\\?*:^&!`~@#$$+=<>\?\*;|/]+$').test("me")) {
alert("good");
}
else {
alert("invalid characters");
} return...
I have the pages that I want to set as a goal in Google Analytics but there is a part of the URL that is dynamic number (3 integers). How do I specify such a URL with regex?
URLs are:
/info.php?id=XXX&sent=ok
I am using this regular expression
/info.php?id=^[0-9]{3}$&sent=ok
But it is not working.
What is wrong?
...
here is a regex i got from: a blog i can't link to because i am new... just google amazon short url and click on the blog post by noah coad
as you can see from this page... it is supposed to extract the unique product id from any amazon url so you can shorten it... or use it to pull info from amazon apis.
here is the sample code i am t...
Hi All,
Just wondering if you had any thoughts on this problem. I want to make it clear that this is for a coding DEMO. So this code is not ever going to become production code.
I would like to write a class which converts any of these URLs,
www.google.co.nz
WWW.google.co.nz
google.co.nz
http://google.co.nz
to this,
http://www.go...
I need a regular expression for finding class declarations so I can add a #define before the "class" keyword. The regular expression doesn't have to be perfect, just good enough that it catches most of the cases.
...
How can you replace the match with the given replacement recursively in a given directory and its subdirectories?
Pseudo-code
import os
import re
from os.path import walk
for root, dirs, files in os.walk("/home/noa/Desktop/codes"):
for name in dirs:
re.search("dbname=noa user=noa", "dbname=masi user=masi")
...
I followed a blog post here to use a custom validator to validate a list of emails. However, the Regex expression in the article:
Regex emailRegEx = new Regex(@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*",
RegexOptions.IgnoreCase);
allows this email address through:
"[email protected] [email protected]"
which is ...
I have following text in a text file
This is some text for cv_1 for example
This is some text for cv_001 for example
This is some text for cv_15 for example
I am trying to use regex cv_.*?\s to match cv_1, cv_001, cv_15 in the text. I know that the regex works. However, it doesn't match anything when I try it in VIM.
Do we need to d...
Given a source text like
nin2 hao3 ma
(which is a typical way to write ASCII Pinyin, without proper accentuated characters)
and given a (UTF8) conversion table like
a1;ā
e1;ē
i1;ī
o1;ō
u1;ū
ü1;ǖ
A1;Ā
E1;Ē
...
how would I convert the source text into
nín hǎo ma
?
For what it's worth I'm using PHP, and this might be a regex I'm l...
Say, I have a line that contains the following string:
"$tom" said blah blah blash. "$dick" said "blah blah blah". "$harry" said blah blah blah.
and I want to extract
"$dick" said "blah blah blah"
I have the following code:
my ($term) = /(".+?" said ".+?")/g;
print $term;
But it gives me more than I need:
"$tom" said blah ...
How would I do a regex match as shown below but with quotes around the ("^This") as in the real world "This" will be a string that can have spaces in it.
#!/bin/bash
text="This is just a test string"
if [[ "$text" =~ ^This ]]; then
echo "matched"
else
echo "not matched"
fi
I want to do something like
if [[ "$text" =~ "^This ...
I have a question about a regex. Given this part of a regex:
(.[^\\.]+)
The part [^\.]+ Does this mean get everything until the first dot? So with this text:
Hello my name is Martijn. I live in Holland.
I get 2 results: both sentences. But when I leave the + sign, I get 2 two characters: he, ll, o<space>, my, etc. Why is that?
...
/^[a-d][a-d]*(?:_[a-d]+)*$/
I'm using the above regex in jquery where I call it on every keypress on an input field. It works exactly as intended which is a problem because I'm running a dynamic update too. You can tell for yourself what it does, but the point here is the underscore _. It's meant to be followed by a character a-d and t...
Hi ,
i am no RegEx expert.
I need to extract a certain number out of an HTML table.
An example:
<td>13</td><td>
</td><td align="right">29.543</td>
<td align="right">1.777</td>
<td align="right">2.588</td>
</tr><tr><td><a href="player.php?p=84668" >Caterdamus</a></td>
<td>7</td><td>
Meister</td><td align="right">9.874</td>
...
i have a string value that i have to insert in mysql database. and i have to escape some literal like (' , " ,% ,) in this string so how can i use regex for that
...
I need a CLR Regex for fractions or whole numbers and fractions where
1/2 is correct
12 2/3 is correct too
and a minus sign can popup just before any number.
I first came up with -?([0-9]* )?-?[0-9]+\/-?[0-9]+ but that seems to allow 2/7 12 too for example.
...