How do i write a regex that matches the syntax in either perl ruby javascript
The syntax is like /my pattern here/modifiers where modifiers are i, g and other single letters.
I wrote the below however that wouldn't allow me to escape escape / with using . AFAIK i can write /Test\/Pattern/i in those languages to match the text Test/Pat...
What is the regex to match a string with at least one period and no spaces?
...
Hello. I am using tinyperl with the following script:
@lines=<STDIN>;
foreach (@lines) {
s/\\(.)/($1 eq '"' or $1 eq '\\') ? $1 : '\\' . $1/eg;
print;
}
I would like each backslash to be considered only with the following character, and remove the backslash only if the following character is a double quote or another backslash...
Hello,
I am trying to parse some object elements from a PDF file using re module of Python. My goal is to parse each PDF object using a regular expression.
A PDF object example is the following:
1 0 obj
<<
/Type /Catalog
/Pages 2 0 R
>>
endobj
2 0 obj
<<
/Type /Pages
/Kids [ 3 0 R ]
/Count 1
>>
endobj
...
When I u...
I want to search for all elements in an array which have the same starting set of characters as an element in another array. To make it clear:
@array = ("1a","9","3c");
@temp =("1","2","3");
I want to print only 1a and 3c. When I try to use the following program it prints out all the elements in the array instead of the two I want:
f...
Possible Duplicate:
passing variable to a regexp in javascript
I have a variable:
resource = "user";
I want to insert that variable into a predefined RegExp (replacing variable beneath):
/^\/variable\/\d+$/
How could I do that?
...
suppose to have the following string:
commandone{alpha} commandtwo{beta} {gamma}commandthree commandtwo{delta}
and I want to abtain:
commandone{alpha} beta {gamma}commandthree delta
well I'm triying with regex and sed, I can easily find if is it present the pattern I look for
/commandtwo{.*}/ but not erasing commandtwo and the foll...
How can I count the amount of spaces at the start of a string in Perl?
I now have:
$temp = rtrim($line[0]);
$count = ($temp =~ tr/^ //);
But that gives me the count of all spaces.
...
Input string is something like this: OU=TEST:This001. We need extra "This001". Best in C#.
...
I'm in notepad++ and I need to add a / right before the closing > in the following line:
<meta name="description" content="*****">
the ***** above is a bunch of text that I need left in place, and it changes from page to page, thus my need for some find / replace method that is superior to what I would normally be capable of. I assu...
Possible Duplicate:
Can regular expressions be used to match nested patterns?
I am writing a regexp to check if the input string is a correct arithmetic expression. The problem is checking if there are enough opening and closing parentheses.
Expressions:
(1)
(((1)
((1))))
I think lookahead and lookbehind are useful here b...
Hi, I have a regex that will validate to make sure I have a number. but it passed if the string I'm checking is "" as well. how can I make a "" fail?
^(\\d|-)?(\\d|,)*\\.?\\d*$
...
Is it possible to have a regex to match a string with alternating 0 and 1? It can end in 0 or 1 and length is arbitrary.
...
There is a web site, what i want to parse. The source is the following
<tr> <td><a
href="http://www.z104.com/"><b>WNVZ</b></a>
- Z104</td> <td>Norfolk</td> <td>Virginia</td> <td><img
src="mp3.gif" alt="MP3" width="12"
height="12"></td> <td><a
href="http://provisioning.streamtheworld.com/pls/WNVZFM.pls">64
...
According to MDC https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/RegExp/exec the following code should log each of the global matches for this regexp.
var str = "(^|\\+)(1\\+1)($|\\+)";
var regex = new RegExp(str, "g");
var result;
var testString = "1+1+1";
while ((result = regex.exec(testString)) != null)
{
con...
So I have a bunch of lines like this -
$ns duplex-link n1 n2 10mb 10ms DropTail
$ns duplex-link-op n1 n2 10mb 10ms queuePos 0.5
$ns duplex-link n2 n3 10mb 10ms DropTail
$ns duplex-link-op n2 n3 10mb 10ms queuePos 0.5
$ns duplex-link n3 n4 10mb 10ms DropTail
$ns duplex-link-op n3 n4 10mb 10ms queuePos 0.5
Now here's the problem. I wan...
I have a list of 350 addresses in a single column excel file that I need to import to a SQL table, breaking the data into columns.
content of the Excel cells is such as this one
Courtesy Motors 2520 Cohasset Rd - Chico, CA 95973-1307 530-893-1300
What strategy should I apply to import this in a clean fashion?
I was thinking
NAME ...
I'm new to .NET and having a hard time trying to understand the Regex object.
What I'm trying to do is below. It's pseudo-code; I don't know the actual code that makes this work:
string pattern = ...; // has multiple groups using the Regex syntax <groupName>
if (new Regex(pattern).Apply(inputString).HasMatches)
{
var matches = new...
Hey guys, I am making an application using C# in Visual Studio that minifies CSS code. Now I came across a piece of code that strips all prefixes for the # ID selector.
strCSS = Regex.Replace(strCSS, @"[a-zA-Z]+#", "#");
However, this would also remove any class names in front the ID selector. For example,
#interior .field#user-comme...
I have a list of words in an array. I need to look for matches on a string for any of those words.
Example word list
company
executive
files
resource
Example string
Executives are running the company
Here's the function I've written but it's not working
$matches = array();
$pattern = "/^(";
foreach( $word_list as $word )
{
$p...