regex

Javascript function involving use of regex

I am allowing a user to enter dimensions of a box through form fields. the permissible values are: positive integers must end with px or % Sample valid numbers are 300px or 70% In addition, I want to place some extra validation logic: If entered value is in percentage, then the number must lie in the range 0 > x <=100 If the numb...

Simple Python Regex Find pattern

Hi Everyone, I have a sentence. I want to find all occurrences of a word that start with a specific character in that sentence. I am very new to programming and Python, but from the little I know, this sounds like a Regex question. What is the pattern match code that will let me find all words that match my pattern? Many thanks in a...

lex (flex) generated program not parsing whole input

I have a relatively simple lex/flex file and have been running it with flex's debug flag to make sure it's tokenizing properly. Unfortunately, I'm always running into one of two problems - either the program the flex generates stops just gives up silently after a couple of tokens, or the rule I'm using to recognize characters and strings...

Remove Duplicate Numbers and Operators from String

I'm trying to take a string which is a simple math expression, remove all spaces, remove all duplicate operators, convert to single digit numbers, and then evaluate. For example, an string like "2 7+*3*95" should be converted to "2+3*9" and then evaluated as 29. Here's what I have so far: expression.slice!(/ /) # Remove whitespace exp...

What is the REGEX for a number followed by a period?

EG something of the form: 12. or 1. or 143. Thanks. ...

.NET Regular Expressions - Finding, Replace

I have a string containing address and a phone number (US format; (xxx) xxx-xxxx). E.g., 1243 K. Beverly Bld. # 223 Los Angeles, CA 41124 (213) 314-3221 This is a single string, I need to extract phone number out of it using regex. I could have used string tokens, but there are chances that some invalid data is also concatenated with ...

Regex to validate URL - Not checking for HTTP?

I know there are tonns of questions on here to validate a web address with something like this /^[a-zA-Z]+[:\/\/]+[A-Za-z0-9\-_]+\\.+[A-Za-z0-9\.\/%&=\?\-_]+$/i The only problem is, not everybody uses the http:// or whatever comes before so i wanted to find a way to use the preg_match() but not checking for http as a must have but mor...

regex for characters

Hello, In C# i'm using RegexValidator to validate a field which can contains only L,l,M,m,D,d values. I tried to use [RegexValidator("[l|L][M|m][D|d]" ... , but this does not work. Any ideas? Thanks ...

How to use regular expressions to extract information from mailto links

I want to write a regex for the following: Pattern1: mailto:[email protected] The regex1 should match all the strings that start with mailto: Pattern2: mailto:[email protected]?subject=Indian&body=hello The regex2 should extract the query string (string after ?) ...

How to parse just the text from a Word Doc using Python?

When you try opening a MS Word document or for that matter most Windows file formats, you will see gibberish as given below broken intermittently by the actual text. I need to extract the text that goes in and want to ignore the gibberish -- which is something like given below. How do I extract only the text that matters, and ignore rest...

How to use square bracket inside PHP Regex class?

I would like to add [ and ] in my validation Regex that already accept all numeric, underscore, period and alphanumeric character. Here is the regex working: $regex = "^[._a-zA-Z0-9-]*$"; But when I try : $regex = "^[.\\[\\]_a-zA-Z0-9-]*$"; or $regex = "^[.\[\]_a-zA-Z0-9-]*$"; It doesn't work (I have read to double escape in...

Regex for matching markup in PHPish markup?

Hello, I am creating a project, and I need to be able to use a regex(or if something else is preferable?) Basically, I need to convert a PHPish markup code page so that the "non-code" is converted into "code." For instance: Orginal: <?code echo 'some text'; ?> <head> </head> <body> </body> <?code echo '</html>'; ?> Converted: ...

Remove text that is in the middle of <b></b>

I Have Text in the middle of <b></b> Eg: La <b>la</b>: the 1 <br></br>Aventuroj <b>aventuro</b>: adventure 2 <br></br>de <b>de</b>: by, from, of, since 3 <br></br>Mirlando <b>miri</b>: marvel, marvel at, wonder<br/><b>lando</b>: country, land 4 <br></br>by <b>ba</b>: bah, nuts, pooh 5 <br></br>for <b>for</b>: away 6 <...

JavaScript Regex: Make ungreedy

I have this regex which looks for %{any charactering including new lines}%: /[%][{]\s*((.|\n|\r)*)\s*[}][%]/gm If I test the regex on a string like "%{hey}%", the regex returns "hey" as a match. However, if I give it "%{hey}%%{there}%", it doesn't match both "hey" and "there" seperately, it has one match"hey}%%{there". How do I make...

help using Java Matcher to modify a group

I want to match on a regex and modify the match. here is my function. right now, my method doesn't change the input at all. what is wrong? thanks. Matcher abbrev_matcher = abbrev_p.matcher(buffer); StringBuffer result = new StringBuffer();//must use stringbuffer here! while (abbrev_matcher.find()){ //System.out.print...

query check if its latitude or just text on map

on search i want to check if query is latitude and longitude or just text search with php. $query = '-122.0307642, 37.3316930'; latitude and longitude can have '-' in them also. what preg_match pattern it will be for this? ...

Regex: change the order of the controls

Hi, I would like to check if a string contains: at least 1 number at least 2 characters (uppercase or lowercase) This is the regex I though I might use: (?=(?:.*?\d))(?=(?:.*?[A-Za-z]){2}) With aa1 the test gives a false statement, while with a1a or 1aa it gives a true result. The strange thing is that if I change the order of th...

Regex for white space and then line end

I am struggling to find this - I need to strip all empty lines which might have white space before them The alternative is messing about in Excel - I am using TextPad ...

How can I use String#scan to scan multiple lines separated only by a carriage return, not a new line

I have a method which scans plain text (specifically in the QIF format) looking for dates which occur after a 'D' on a new line: dates = "D2009-11-12\nPApple Store\nMSnow Leopard\nD2009-11-13\nPApple Store\nMiMac".scan(/^\s*D"?(.+?)[\r\n?|\n]/m) # => [["2009-11-12"], ["2009-11-13"]] "D2009-11-12\r\nPApple Store\r\nMSnow Leopard\r\nD200...

regular expression for pick the work from the group

Hi How to pick the work using RegEx |=|3|=|5|=|5|=|3|=|Yes|=|gdfsgsdf i want to pick yes from the |=|3|=|5|=|5|=|3|=|Yes|=|gdfsgsdf Can u tell me the preg match regular expression for the above collection ? ...