def boldword(text, needle):
return mark_safe(re.compile(r"\b(%s)\b" % "|".join(map(re.escape, needle.split(' '))), re.I).sub(r'<strong>\1</strong>', text))
This is currently my function to bold a string text given a needle. (Like Google...they bold the text for you when you do a search).
When the needle is "the show", it will not...
Assuming I have this string: "abc{def{ghi{jkl}mno{pqr}st}uvw}xyz"
and I want to match this: "{def{ghi{jkl}mno{pqr}st}uvw}"
what should my regular expression look like..?
In other words, the match should start with "{" and end with "}", but it must have as many {'s as }'s in between.
...
i dont undestand the () in regexp.
eg. what is the difference between these lines:
"/hello/"
"/(hello)/"
...
could someone explain these 2 terms in a understandable way?
...
i want to get the word Asarum in the below line:
<A HREF="http://www.getty.edu/vow/TGNFullDisplay?find=&place=&nation=&english=Y&subjectid=1062783">Asarum</A>
i tried with:
preg_replace('/<a.*?>/i', '', $link);
preg_replace('/<\/a>/i', '', $link);
echo $link;
but it doesn't work. nothing was cut out.
coul...
Hi
I am working in asp.net. I am using Regular Expression Validator
Could you please help me in creating a regular expression for not allowing special characters other than comma. Comma has to be allowed.
I checked in regexlib, however I could not find a match. I treid with "^(a-z|A-Z|0-9)*[^#$%^&*()']*$" . When I add other characters...
How to replace all " " siblings from JSON string?
{"Cat":"laps milk","Dog":"Woofs at Postman","Bird":"Jumps over the river","I":"Want to learn Regexp"}
And btw, advice me please some good article or book from where I could finally learn Regexp :(
...
Possible Duplicate:
What regular expression can never match?
I would like to write regular expression, which will match nothing, that is corresponding to empty language. Empty language is regular, so there should be a way to write regular expression for it.
I'm particularly interested in how to write it in Java using API prov...
I have a SQL Server database (service-based) with a table (Contact). Instead of having multiple tables, I decided to have one delimited string called Emails. So how could I use a Regex and a delimiter to add on to the string.
...
I'm new to regular expressions in php.
I have a long string of html. I want to find all occurences of:
@any_username_after_an_at_sign
Could somebody help me recover all of the usernames on a page?
I think you use preg_match but I don't know the regular expression to use.
Thanks!!
...
Hello, at the registration process I want to enforce typing first and last name of the users. For this purpose, I need to write a regex.
What I need is the username should accept any char input but starting with a number like (1sdasd) or an empty string (like pressing space at this field which makes an empty string " ")
What can be the...
Hello,
I need a regular expression to detect a span-element where the order of id and class doesn´t matter. The name of the class is always the same, the id is always a fixed number of digits, for example:
<span class="className" id="123">
or
<span id="321" class="className" >
My approach for a regular expression in java was:
Str...
I'm writing a little web service which generates SO/SF/SU/MSO user flair in the form of an image with various "themes". I find this preferable to using the HTML/JS solutions offered by SO as it's more flexible and also works better in forum signatures.
I'm retrieving the data using the apparently unofficial API (More info here). I can h...
is there a way to tell preg_match_all to find all sequences that matches a certain pattern but omits another pattern?
eg.
<a>computers</a>
<a>books</a>
<a>pens</a>
i want to match books and pens but not computers.
so using:
preg_match_all('/<a>.*?<\/a>', $string, $array);
wont do.
would appreciate some help with this. thanks!
...
i've got an array with string values.
i want to search for a pattern with regex and if matched, remove the key containing the value.
how would i accomplish this?
...
Hey everyone,
I'm trying to use regex in Perl. What I was wonder was if it is possible to store all matches to the expression into an array? I know I can use the following: ($1,...,$n) = m/expr/g; but it seems as though that can only be used if you know the number of matches you are looking for. I have tried my @array = m/expr/g; but ...
Could you provide a regex that match Twitter usernames?
Extra bonus if a Python example is provided.
...
I have a big paragraph which I need to split into lines such that each line must not have more than 100 characters and no words must be broken. How would I go about doing this? I guess with regular expressions is the best way but I'm not sure how.
...
EDIT: It was some issue with Notepad++'s regex engine. The regex worked fine in Python.
I'm working in Notepad++. I tried to make a regexp that would transform this (if you're curious, it's a Spanish guide for a game):
*Acero: En la Estatua de Gabomba
**Absorbe PV de un enemigo
To this:
====Acero====
*En la Estatua de Gabo...
I have the following values that I want to place into a mysql db
The pattern should look as follows, I need a regex to make sure that the pattern is always as follows:
('', '', '', '', '')
In some rare execution of my code, I hower get the following output where one of the apostrophes disapear. it dissapears every now and then on the...