regex

If you are really good at Python and Regex, please help fix function.

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...

Find matching brackets using regular expression in PHP

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. ...

help with regular expression

i dont undestand the () in regexp. eg. what is the difference between these lines: "/hello/" "/(hello)/" ...

what does lazy and greedy means in regexp?

could someone explain these 2 terms in a understandable way? ...

help with reg_replace()

i want to get the word Asarum in the below line: <A HREF="http://www.getty.edu/vow/TGNFullDisplay?find=&amp;place=&amp;nation=&amp;english=Y&amp;subjectid=1062783"&gt;Asarum&lt;/A&gt; 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...

Regular Expression

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 &#160; siblings from JSON string in JavaScript?

How to replace all "&#160;" siblings from JSON string? {"Cat":"laps&#160;milk","Dog":"Woofs&#160;at&#160;Postman","Bird":"Jumps&#160;over&#160;the&#160;river","I":"Want&#160;to&#160;learn&#160;Regexp"} And btw, advice me please some good article or book from where I could finally learn Regexp :( ...

Is it possible to write regular expression, evaluation of which will always fail?

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...

Use a Regex to form delimited string for SQL Server

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. ...

Simple regular expression question: How to find all @username mentions on a page of html?

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!! ...

Django RegexField

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...

Need regular expr. for html element where order of attributes doesn´t matter

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...

.Net Regex to parse specific JSON format

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...

Omit a pattern?

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! ...

remove a key if value matches a pattern?

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? ...

How can I store regex captures in an array in Perl?

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 ...

regex for Twitter username

Could you provide a regex that match Twitter usernames? Extra bonus if a Python example is provided. ...

How do I re-wrap a paragraph to a certain line length?

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. ...

Why doesn't this regular expression work? [SOLVED]

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...

Regex pattern to match where my code breaks

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...