regex

Ant regexp. Read value of matched expression.

I need to replace all occurrence of some regular expression in xml file with proper values loaded from property file. As example in xml file I have < port=${jnpPort}/> in property file I have port=3333 I want to have xml file with entries like < port=3333/> Now using <replaceregexp match="\$\{(.*)\}" replace="${\1}" flags="g" byli...

mod_rewrite rule: if URL contains a certain string

My client keeps editing the structure of the navigation in the website, which is leading to some mod_rewrite issues. How could i make this rule: RewriteRule ^studios/about-studios/artist-noticeboard noticeboard2.php?section=studios&subSection=studio-artists [L] to work if the url contains "noticeboard"? Like this: RewriteRule ^IF CON...

regular expression to extract @name symbols from tweet

Hello All, I would like to use regular expression to extract only @patrick @michelle from the following sentence: @patrick @michelle we having diner @home tonight do you want to join? Note: @home should not be include in the result because, it is not at beginning of the sentence nor is followed by another @name. Any solution, tip,...

PHP : Transform links in custom tags with regular expression

Hi, I am trying to get a working regular expression to convert standard HTML code to a custom format (needed for data export). For exemple within the following code : <a href="toto.php">Toto </a> bwahaha <td width="49%" bgcolor="#FF9E39" style="padding-left: 10px; padding-top: 3px; padding-bottom: 3px; border-bottom: 5px solid rgb(255...

Find best matching row in MySQL (InnoDB)

I have the following test string engine/mail/key and a table which looks like this: +-------------+ | query | +-------------+ | engine | | engine/pdf | | engine/mail | +-------------+ I want to find the best matching row. Best match is specified by the most matching characters from the start of the string/row. I have con...

How to find out emails and names out of a string in javascript

I am using a cool widget to import email addresses out of gmail/homail/yahoo etc. The widget is still beta and I guess thats why it does not allow a lot of configuration. It actually just fills a textarea with the following data: "Name one" <[email protected]>, "Name Two" <[email protected]>, "And so on" <[email protected]> So I wondered if so...

Maximum expression string length in regexp (MATLAB)

I wonder how long expression string one can use in REGEXP function in MATLAB? For example to list many words to match, like 'abc|defg|hij|...'. Worked fine for me with about 500 words (~3K characters), but with very large list (>300K) MATLAB just crashed without any error log. Anybody have an idea on the limit? May it depend in expressi...

Fast method to find regex matches in a large document using javascript?

I need to search the text in a HTML document for reg-exes(emails, phone numbers, etc) and words. The matches need to be highlighted and be made anchor-able so that a link can be generated to jump to the location of the matches. So not only does it need to find matches using patterns in needs to do a replace do add the proper html code. ...

What does /[\[]/ do in JavaScript?

I am having trouble googling this. In some code I see name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); /[\[]/ looks to be 1 parameter. What do the symbols do? It looks like it's replacing [] with \[\] but what specifically does /[\[]/ do? ...

Need Help Parsing File for This Pattern "Feb 06 2010 15:49:00.017 MCO"

Need to parse a file for lines of data that start with this pattern "Feb 06 2010 15:49:00.017 MCO", where MCO could be any 3 letter ID, and return the entire record for the line. I think I could get the first part, but the returning the rest of the line is where I get lost. Here is some sample data. Feb 06 2010 15:49:00.017 MCO ...

PHP: How to Remove Space Additionally to the Special Chars?

Hello, in my functions.php if have this code: echo '<a href="' . preg_replace('/\s/', '-', $search) . '-keyword1.html">' . urldecode ($search) . '</a>'; this removes the special chars.. but how can i additonally add remove space and replace it with - and remove " so, if someone types in "yo! here" i want yo-here thank you! ...

How do I use the C# Regular Expression object to make this substitution?

I am writing a method to take a DevExpress "filter" string and convert it to a useable SQL string. For the most part this is easy with simple string substitutions here or there. One thing, however, has me scratching my head because I've just not taken the time to learn Regular Expressions in C#/.NET. When a decimal number is used, Dev...

Can someone explain this code snippet in PHP?

preg_replace(array('#/(.?)#e', '/(^|_|-)+(.)/e'), array("'::'.strtoupper('\\1')", "strtoupper('\\2')"), $text); I've never used regex this way,how does it work? ...

ruby: optimize => phrase.split(delimiter).collect {|p| p.lstrip.rstrip }

ruby: What is the most optimized expression to evaluate the same as result as with phrase.split(delimiter).collect {|p| p.lstrip.rstrip } ...

Perl substitution using string that contains a dollar sign on windows

I'm using perl on windows and am trying to do a one liner using perl to substitute a placeholder in a file using a windows variable that contains a dollar sign. Does anyone know what the correct usage is to make it work with the dollar sign. I've tried various ways and can't seem to get it to work. For example, I have a properties file...

Extract numbers from a string - Java

Hi! I have a String variable (basically an English sentence with an unspecified number of numbers) and I'd like to extract all the numbers into an array of integers. I was wondering whether there was a quick solution with regular expressions? UPDATE Thanks for your answers. I used Sean's solution and changed it slightly: LinkedList<St...

Still don't understand regex - How can I learn it?

Possible Duplicates: How do I learn Regular Expressions? Learning Regular Expressions I've read regex tutorials, books, stackoverflow questions. But I can't 'get' regex. I don't know why. But I always end up asking for help writing regexes. Has anyone discovered a good way to learn regex? ...

RegEx: Matching a especific string that is not inside in HTML tag

<tag value='botafogo'> botafogo is the best </tag> Needs match only botafogo (...is the best) and not 'botafogo' value my program "annotates" automatically the term in a pure text: botafogo is the best to <team attr='best'>botafogo</team> is the best and when i "replace all" the "best" word, i have a big problem... <team att...

PHP regex help - Find a Match Within Another Match and replace something

guys i have arrays in which i have to match this kind of text then remove spaces in-between the words , Name:'lofse erbbnwq qweqw-qweqw' KKK Name:'lofsdsse erbsdsdbnwq sds sdsd sdqwsdseqw-qwsdseqw' KKK Name:'lofsse esdsdbnwq sds sds sddseqw-qwseqw' KKK i read somewhere that it will work like this, but i tried and its not working ...

php Replacing multiple spaces with a single space

I'm trying to replace multiple spaces with a single space. When I use ereg_replace, I get an error about it being deprecated. ereg_replace("[ \t\n\r]+", " ", $string); Is there an identical replacement for it. I need to replace multiple " " white spaces and multiple nbsp white spaces with a single white space. ...