regex

Java regex special construct

Possible Duplicate: What is a regex independent capturing group? Which is the difference between: (?:X) X, as a non-capturing group and (?>X) X, as an independent, non-capturing group I can't figure out how to use the last. ...

help with regex - how can i make some urls no-follow?

Ok so i've made this function which works fine for converting most urls like pies.com or www.cakes.com to an actual link tag. function render_hyperlinks($str){ $regex = '/(http:\/\/)?(www\.)?([a-zA-Z0-9\-_\.]+\.(com|co\.uk|org(\.uk)?|tv|biz|me)(\/[a-zA-Z0-9\-\._\?&=#\+;]+)*)/ie'; $str = preg_replace($regex,"'<a href=...

Regular expressions get a single word out of a common phrase

hi, i have a phrase like this Computer, Eddie is gone to the market. I want to get the word Eddie and ignore all of the other words since other words are constant, and the word Eddie could be anything. How can I do this in regular expression? Edit: Sorry I'm using .NET regex :) ...

How to make a python regex?

Hello everybody, I am working on a loginMiddleware class for Django. This middleware class must send a user to the login page when it's not logedin. But there are a few exceptions. Because i run the build-in django server i had to make a media url. But know is de problem that when the login page loads a javascript file, the javascript...

php regular expression help?

how to i replace Apple 123456 to Apple 1|Apple 2|Apple 3|Apple 4|Apple 5|Apple 6 by php pcre? ...

Java regex to validate a name

To validate names that can be John, John Paul, etc. I use this regex: String regex = "[A-Z]([a-z]+|\\s[a-z]+)"; but when I do: boolean ok = Pattern.matches(regex, "John Paul"); the matches fail? Why? I want to use matches to validate the string as whole... Is that regex wrong? ...

Perl: parse hex-encoded string into array with regex

Hello, I'm quite new to Perl development, and I'd like to perform a following task: My script receives hex-encoded string as command-line param. Then I must decode this string and write it to output file like a C++ array with initialization from data given. For example: perl myscript.pl DEADBABEDEADBEEF and the output something like ...

foreach in regular expression?

Possible Duplicate: php regular expression help? hi, i want to replace i like apple apple is good orange is also nice my mom likes banana apple 123 4 the pear is soo sweat my dad loves pear to i like apple apple is good orange is also nice my mom likes banana apple 1 apple 2 apple 3 apple 4 the pear is soo sweat my dad lo...

Replacing all spaces inside <a> tags

Hi, I've been struggling with this for a while now so hopefully someone can help me out. I need to use regex to replace all spaces inside an anchor tag for example. Hello this is a string, check this <a href="http://www.google.com"&gt;Google is cool</a> Oh and this <a href="http://www.google.com/blah blah">Google is cool</a> That is al...

help needed for IDN regex

based on this post link text i came up with a regex for javascript \b(([\w-]+:\/\/?|[\w\d]+[.])?[^\s()<>]+[.](?:\([\w\d]+\)|([^`!()\[\]{};:'".,<>?«»“”‘’\s]|\/))) this one matches urls like http://google.com http://www.google.com google.com and fail for google but when i used japanese characters like 功功.jp ...

REGEX: Appending Single Space between Capitals in Javascript

I got some idea from a C# related thread, but I need it in Javascript. I am try all sorts of things, it doesn't seem to work. name.replace(/[A-Z]/g, / $&/); What I am trying to do is make: FirstName with spaces: First Name But what I get is: / F/irst/ N/ame Any ideas would be much appreciated. ...

Perl Regex Help

I am looking to match strings out of a file that are prefixed /** and have a postfix */ With any number of characters/whitespace/newlines in between. eg: /** anything anything */ I have m/(\/\*\*).*?(\*\/)/ so far, however this does not handle newlines. I know the fix has to be simple, but i have very limited regular exp...

Regex repeated replace

Hi Is it possible to have a single but recurring regex.replace call? e.g. string dateText = "01\.02\\.2008"; string dateSeperators = @"\.|/|\\|-"; string result = Regex.Replace(dateText, dateSeperators, "."); // needs to be fixed. single call possible? The result should give "01.02.2008". Currrently i need 2 runs, first run the above...

regular expression for password field not allowing space

Hi, I need a regular expression for my rails application for password field. any character or number or symbols is allowed except space. Thanks! ...

Some nifty regex to parse some javascript inside HTML

I have some HTML that looks like this: $(document).ready(function(){ $('#cumulative-returns').graph({ width: 400, height: 180, type: 'bar', x_label: 'Month', x_data: ['Jan','Feb','Mar','Apr'], y_label: 'Cumulative Return', y_data: ['5','10','...

What is the most efficient way to repeatedly use regular expressions in a Python loop?

When you're iterating over hundreds of lines in a file, what is the most (and least) efficient way to run regular expressions in Python? Specifically, is the following bad form? for line in file: data = re.search('(\d+\.\d+)\|(-\d+\.\d+)\|(.*?)\|(.*?)\|(\d+:\d+\s+\w+)\sTO\s(.*?)',line) one = data.group(1) two = data.group(2) th...

strip HTML tags with certain content from string

$text = "<p>keep me</p> <p>strip me &nbsp;</p> $pattern = "/<[^\/>]*>(\&nbsp\;)*<\/[^>]*>/"; $text = preg_replace($pattern, '', $text); Hi, I need to strip "quasi-empty" p tags from a html string. there's always only a &nbsp; as a trigger in the p element. how can I strip it with regex? ...

Regex / javax.validation help -- verifying non-whitespace present -- Java.

I'm trying to validate some fields before persisting them to the database. In particular, I need to know that a String contains a non-whitespace character. I'm using the javax.validation.constraints.Pattern annotation, as follows: @Pattern(regexp = "[^\\s]") private String field; This seems to throw the ConstraintViolation on every ...

Regex works differently on different computer

I'm writing a program which uses regex to match incoming data. The regex works on the computer I'm coding on, but it doesn't work on the client computer I'm testing on. It works on my computer in debug mode, release mode, and being run straight from the bin. What could possibly make a regex work differently? Regex: const string _patter...

Problem with ereg deprecated

Can some please help me to rewrite these code: if (eregi($asked,$accepted)) { $this->plot_type = $which_pt; return true; } else { $this->DrawError('$which_pt not an acceptable plot type'); return false; } Any help will be highly appreciated, I have tried all the fix I got through Google but none has been able to fix it. Thanks. ...