regex

Rewrite this regexp to match only when other char is present

I have this regexp Pattern pattern = Pattern.compile("\\{([^\\}]+)\\}"); to match {a1|a2|a3} and {a4} format How can I rewrite the above line, to include those matches only when a pipe | is present, so to match {a1|a2|a3} and do not match on {a4} ...

Inner join on regexes

I have an inner join on regular expressions - it is very slow. Is there any easy way to speed this up? I am using postgres. FROM A inner join B ON trim(lower(replace(replace(replace(B.enginequery,',',' '),'"',' '),'+',' '))) = trim(lower(A.keyphrase)) OR trim(lower(replace(replace(replace(B.enginequery,',',' '),'"',' ')...

Regex: How do I match some regex logic 1 or more times?

I already have some regex logic which says to look for a div tag with class=something. However, this might occur more than once (one after another). You can't simply add square brackets around that complex regex logic already (e.g. [:some complicated regex logic already existing:]* -- so how do you do it in regex? I want to avoid having ...

Parsing a context-free grammar in Python

What tools are available in Python to assist in parsing a context-free grammar? Of course it is possible to roll my own, but I am looking for a generic tool that can generate a parser for a given CFG. ...

Force Decimal Regex

Hi, I'm looking for a regex or a way to format the NumberValidator so that only decimal places are allowed. The domain="real" allows you to put integer values, but I need to force the user to but in 2.0 if they want an integer. This is because they pass through a Castor mapping file, it complains if it gets an integer when it expects...

Help Me Writing a Simple Regular Expression

I have the following text: txtAddressSup.Text I want the Sup to be replaced by Cus while the whole text remains as is. I have many texts that are in this format: xxxxxxxSup.xxxxx ...

Regular expression with no maximum limit

I Need a regular expression which accepts all types of characters (alphabets, numbers and all special characters), and miniumum number of characters should be 15 and no limit for maximum characters. ...

RegExpValidator never matches

Hi, I've got a class that's meant to validate input fields to make sure the value is always a decimal. I've tested the regex here: http://livedocs.adobe.com/flex/3/html/help.html?content=validators_7.html, and it looks like it does the right thing, but in my app, I can't seem to get it to match to a number format. Class Definition: p...

Attempting to extract a pattern within a string

I'm attempting to extract a given pattern within a text file, however, the results are not 100% what I want. Here's my code: import java.util.regex.Matcher; import java.util.regex.Pattern; public class ParseText1 { public static void main(String[] args) { String content = "<p>Yada yada yada <code> foo ddd</code>yada yada ...\n...

Algorithm to match list of regular expressions

I have two algorithmic questions for a project I am working on. I have thought about these, and have some suspicions, but I would love to hear the community's input as well. Suppose I have a string, and a list of N regular expressions (actually they are wildcard patterns representing a subset of full regex functionality). I want to k...

Regex in Flex 3: How to Wrap Quotations Around a Dynamic String?

Hi, I need some Regex help. I need to find beacon_ followed by an alphanumeric code and then wrap it in quotation marks. For something static, like the example, below it's straight forward. myReturn = myReturn.replace( 'id=beacon_80291ee9b3', 'id="beacon_80291ee9b3"'); But, my problem is that the part after beacon is a random alpha...

Extract number from string in MSBuild

I would like to extract the number from a string in MSBuild. How can I do that using the built in tasks or the MSBuild.Community.Tasks? (RegexMatch might do, but how?) Example: I have the string agent0076 and I would like to get out the number, without the leading zeros: 76 ...

JavaScript Replace - u0009 .... with .replace(/\u0009/g,'');

I'd like to use Javascript to replace all instances of \u009 in a string This doesn't seem to be working: .replace(/\u0009/g,''); Do I need to escape something? ...

Regular expression problem

i have exemple Term:a=27 B=90 C=65 ....and i want only value C and A, C first and A second i have do (C=(\d+)^|A=(\d+)) but no success why please ...

which delimeter to use while spliting String

I need to split this line string in each line, I need to get the third word(film name) but as you see the delimeter is one big blank character in some cases its small like before the numbers at the end or its big as in front of numbers at front. I tried using string split with(" ") regex, and also \t but get the out of the bounds error...

PHP - How to convert the YouTube URL with Regex

How can convert the below youtube urls $url1 = http://www.youtube.com/watch?v=136pEZcb1Y0&amp;feature=fvhl $url2 = http://www.youtube.com/watch?feature=fvhl&amp;v=136pEZcb1Y0 into $url_embedded = http://www.youtube.com/v/136pEZcb1Y0 using Regular Expressions? ...

preg_replace only replaces first occurrence then skips to next line

Got a problem where preg_replace only replaces the first match it finds then jumps to the next line and skips the remaining parts on the same line that I also want to be replaced. What I do is that I read a CSS file that sometimes have multiple "url(media/pic.gif)" on a row and replace "media/pic.gif" (the file is then saved as a copy w...

Add link around img tags with regexp

I would like to add links around image tags with preg_replace(). Before: <img href="" src="" alt="" /> After: <a href="" ..><img href="" src="" alt="" /></a> I would greatly appreciate any help. Thank you very much. ...

asp.net regex help

Hi ive got this regular expression and that extracts numbers from a string string.Join(null,System.Text.RegularExpressions.Regex.Split(expr, "[^\\d]")); so eg, the format of my string is like this strA:12, strB:14, strC:15 so the regex returns 121415 how can I modify the expression to return 12,14,15 instead, any suggestions plea...

Perl regex matching output from `w -hs` command

I'm trying to write a Perl script that will work better with KDE's kwrited, which, as far as I can tell, is connected to a pts and puts every line it receives through the KDE system tray notifications with the title "KDE write daemon". Unfortunately, it makes a separate notification for each and every line, so it spams up the system tra...