I want to accept an arbitrary regular expression from the user and anchor it on both sides in order to enforce a full match (^<user's-regex>$) however I don't know if I have to take into account the fact that the user may have already anchored his regex.
It looks like Perl, C++, .NET and JavaScript all allow double multiple anchoring.
...
I have a string of attribute names and definitions.
I am trying to split the string on the attribute name, into a Dictionary of string string. Where the key is the attribute name and the definition is the value. I won't know the attribute names ahead of time, so I have been trying to somehow split on the ":" character, but am having trou...
Suppose I have a long java String , I need to wrap all whitespaces (length >=2) with <pre></pre> tag... , How to achieve that ?
ex :
before :
String str = "<font color=\"#000000\">A B C D</font>"
after :
<font color=\"#000000\">A B<pre> </pre>C<pre> </pre>D</font>
Between A and B is one whitespace , and not wrapped.
Between B a...
Hi all, i get a longString from object's onclick value
var longString = String(this.onclick);
output like below;
function onclick(event) { window.location.href = "index.html?q1=v1&g2=v2"; }
i want parse that like below;
index.html?q1=v1&g2=v2
how can i do this with pure js or jquery which works with all browser?
Thank you fo...
Hi all,
Suppose I have the following test string:
Start_Get_Get_Get_Stop_Start_Get_Get_Stop_Start_Get_Stop
where _ means any characters, eg: StartaGetbbGetcccGetddddStopeeeeeStart....
What I want to extract is any last occurrence of the Get word within Start and Stop delimiters. The result here would be the three bolded Get below.
S...
Hi-
I'm trying to work with regexes in PHP on my school's news site (running WordPress). The idea is, whenever someone saves a post, all instances of "Regis" (without 'Jesuit' at the end) are replaced with "Regis Jesuit." (I go to Regis Jesuit High School, and they're picky about their branding). Overall this works fine with the followin...
Hi there, I am trying to write a regex that selects everything between two characters.
For example, when the regex encounters a '§' I want it to select everything after the '§' sign, up until the point that the regex encounters a ';'. I tried with a lookbehind and lookahead, but they don't really do the trick.
So for example " § 1-2 bl...
Hi,
I am looking for a way to generate regex from based on the differences between 2 input strings. The regex can then be used to match the 3rd string that is also similar to the 2 input strings.
For example, given 3 strings: f1, f2, and f3
f1:
111xxx222
f2:
111yyy222
f3:
111zzz222
I am wondering if there is a generic way to ...
Hi,
I have this below issue in Perl.I have a file in which I get list of emails as input.
I would like to parse the string before '@' of all email addresses. (Later I will store all the string before @ in an array)
For eg. in : [email protected], i would like to parse the email address and extract abcdefgh.
My intention is to get o...
Hello,
Does anyone know where I can come by a regex that matches any valid C# style regular expression? Is it even possible?
FYI, the reason I'm trying to do this is because I have a mini language which allows regular expressions as part of it's syntax and I cobbled together crummy regex to validate the mini-language statements but it...
Hello,
I have for example a string \try Tester234 where I want to find the Word (partially with digits)
(RegEx => (\w|\d)) after the \try.
But a var_dump($match) outputs that:
array
0 =>
array
empty
1 =>
array
empty
preg_match_all('/^\\try ((\d|\w)*)/i', "\try Tester", $match);
What am I doing wrong?
...
I have two variables that are the result of regex searches.
a = re.search('some regex', str)
b = re.search('different regex', str)
This should return a re object. If they are not None, I want to use the group() method to get the string that it matched. This is the code I am using right now to do this:
if a != None:
a = a.group()
...
Ok Im trying to figure out this regex where I have a word, and on either end of the word it can be a space or no character. Heres an example:
preg_match_all("/( ?)(" . $piece . ")( ?)/is", $fk, $sub);
Where ( ?) is I want that to be "A single character that can only be a space or no character at all". Im trying to basically make a fun...
How do I return the first 5 digits of a string of characters in Regular Expressions?
For example, if I have the following text as input:
1520 Main Street
Apartment 3 63110
How can I return just "15203"
Thank you,
Flea
...
I want to copy many tables with similar names but different prefixes. I want the tables with the wp_ prefix to go into their corresponding tables with the shop_ prefix.
In other words, I want to do something like this:
insert into shop_wpsc_*
select * from wp_wpsc_*
How would you do this?
...
Hi,
I have a database containing Page ojects with html content. A lot of the rows in the db contain this content
<p style="float: left; margin-right: 20px; height: 300px;">
<img src="...">More html ...
</p>
So I created a super simple regex replace:
foreach (var page in db.Pages)
{
str...
I want to do this:
%s/shop_(*)/shop_\1 wp_\1/
Why doesn't shop_(*) match anything?
...
Hi,
I am looking to substitute hash value with perl regular expression /e option. The following code is not working for me.
#!/usr/bin/perl
%hash=( 1 => "aa", 2 => "bb", 3 => "cc" );
$_="name,3";
s/^(name,(\d+).*)/$2,$hash{$1}/e;
print "$_\n";
exit 0;
I am expecting output like this:
name,3,cc
How can I make this work?
Thank...
I'm not very good in regex... so if somebody could help me with this one (maybe trivial)
[update] First i'm not looking for the best way of manipulating xml (SimpleXMLElement,DOM etc... is fine). I'm just looking for this regex out of the context off XML.
i have xml like that
<myxml>
<node>21</node> som text with <entite>some</entite...
I have a string that can range from the empty string to an arbitrary list of comma delimited numbers. For example: "1,2,3"
Unfortunately as I write the code to remove an element I have a bunch of if statements--mainly to deal if it is the first, last, or only element in the list. I keep thinking there has got to be a better way!
For ...