Hi guys, I'm looking for a regex that will change sth. like this:
print "testcode $testvar \n";
in
printnlog("testcode $testvar \n");
I tried %s/print\s*(.\{-});/printnlog(\1);/g but gvim says
print\s*(.\{-});
doesn't match.
Where is my fault?
Is it ok to use '*' after '\s' because later '{-};' will stop the greed?
Thanks in ...
In What regular expressions can never match? /$./ was given as a response. I played around with that a bit, and discovered that the following two lines of code generate different output. The second matches, but the first does not. Can anyone explain why?
$ printf 'a\nb\n' | perl -0777 -ne 'print if m/$./m'
$ perl -0777 -e '$_="a\nb\...
I have encountered this piece of code that is supposed to determine the parent url in a hierarchy of dynamic (rewritten) urls. The basic logic goes like this:
"/testing/parent/default.aspx" --> "/testing/default.aspx"
"/testing/parent.aspx" --> "/testing/default.aspx"
"/testing/default.aspx" --> "/default.aspx"
"/defau...
I have a table that has ordernumber, cancelled date and reason.
Reason field is varchar(255) field and it was written by many different sales rep and really hard to group by the reason category I need to generate a report to categorize cancelation reasons. What is the best way to analyse the reasons with TSQL?
Sample of reasons entered ...
Hi,
As you might know,Visual Studio's Find and Replace feature allows us to use Regular Expression but I don't know how to change something like this :
Math.round((document.getElementById('selectedproductPrixdock').value*document.getElementById('addxdock').value)*100)/100
to this one :
(Math.round((document.getElementById('selectedp...
Does a regular expression exist for (theoretical) tryptic cleavage of protein sequences? The cleavage rule for trypsin is: after R or K, but not before P.
Example:
Cleavage of the sequence VGTKCCTKPESERMPCTEDYLSLILNR should result in these 3 sequences (peptides):
VGTK
CCTKPESER
MPCTEDYLSLILNR
Note that there is no cleavage after ...
I am using RewriteMatch to redirect all traffic from subdir1 to subdir2, while keeping all other parts of the url the same. So for instance,
http://www.mydomain.com/subdir1/
would redirect to
http://www.mydomain.com/subdir2/
I am using this rule:
RedirectMatch 302 /subdir1/.* /subdir2/$1
which works for the url
http://www.m...
Do I really get any benefit out of doing the following (as opposed to just putting the actual regex in place of the ${pcr} in both if statements)? (alot more lines are in the real data set but just using DATA for example.
my $defs = 0;
my $tests = 0;
my $pcr = qr/\s*[\/\\]?\s*/;
while (<DATA>)
{
$defs = ($1 ? 0 : 1) if /<(${pcr})d...
Suppose I have:
my $string = "one.two.three.four";
How should I play with context to get the number of times the pattern found a match (3)? Can this be done using a one-liner?
I tried this:
my ($number) = scalar($string=~/\./gi);
I thought that by putting parentheses around $number, I'd force array context, and by the use of scal...
I have a container of regular expressions. I'd like to analyze them to determine if it's possible to generate a string that matches more than 1 of them. Short of writing my own regex engine with this use case in mind, is there an easy way in C++ or Python to solve this problem?
...
I'm writing a function to "title case" strings e.g. "this is a title" to "This is a Title." The following line doesn't work because the regex group reference is lost (or so I assume). Is there an easy way to uppercase my matching letter in the replace function?
replace( $input, '\b[a-z]' , upper-case('$0'))
...
Hello.
I am working on a project that requires the parsing of "formatting tags." By using a tag like this: <b>text</b>, it modifies the way the text will look (that tag makes the text bold). You can have up to 4 identifiers in one tag (b for bold, i for italics, u for underline, and s for strikeout).
For example:
<bi>some</b> text</i>...
i am parsing binary file. File size can be large. i want to search a some pattern in that file. the string is
anynumber 0 obj<< any
alpha,symbol,digit...anything
>>endobj
Bold text indicates compulsory string.
So, My QUESTION is - should i do it by regular expression or search it by coding. After that i want to store it in a...
Hi all,
I'm relativly new to regular expressions but I managed to create a working expression to validate dates (without leap years, and assuming people enter a valid 30 or 31 digit for a month).
This is the expressen:
/^\d[1-31]{2}\-\d[1-12]{2}\-\d[1900-2009]{4}$/
But I would like to have a dynamic regular expression like:
$yearSpa...
For example, we just want to get the data inside double quotes from a list of strings:
String result = string.Empty;
List<string> strings = new List<string>();
strings.add("string=\"string\"");
strings.add("stringwithspace=\"string with space\"");
strings.add("untrimmedstring=\" untrimmed string\"");
strings.add("anotheruntrimmedstring...
I have strings of 15 characters long..i am performing some pattern matching on it with the use of regular expression.
i want to know the position of string where the isMatch() function returns true.
Is there is any function that return
index position of a string
I want to perform some operation on that index.
...
I want to check if my string holds following value or not..
My condition is
48-57(1 or more time)32(or)10(or)13(then)48(then)32(or)10(or)13(then)111981066060
how to write regular expression for above condition. bracket text indicates occurrence.
I tried it but it wont work.Thanks in advance.
Samples:
4850324810111981066060
501...
Hello,
I've been trying to debug a script of mine and I can't get my head around what's wrong with this:
var date = new Date("19871104071535".replace(
/^(\d{4})(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/,
'$4:$5:$6 $2/$3/$1'
));
alert(date);
It works in Firefox, IE, Chrome but Safari gives me an "Invalid Date" error. Any ideas?
...
I am trying to vocab list for a greek text we are translating in class, I want to be able to replace every space or tab character with a paragraph mark, so that every word appears on it's own line. Can anyone give me the sed command, and explain what it is that I'm doing? I'm still trying to figure sed out.
...
Hello all,
I am using qtranslate wordpress plugin to store blog content in multiple languages. Now I need to extract content from qtranslate tags.
$post_title = "<!--:en-->English text<!--:--><!--:it-->Italian text<!--:-->";
What would be the php code & regular expression to return text and language from this string?
Thanks a lot!
...