regex

separate integers and text in a string.

Hi, I have string like fullData1 upto fullData10 in this i need to separate out the integers and text part. how do I do it using javascript. ...

Parsing HTML Table using Regex

Hello Everyone, I am trying to extract the contents of the table using Regex. I have removed most of the tags from the table, i am stuck with <br> , <a href >, <img > & <b> How to remove them ?? for <b> tag i tried this Regex \s*<b[^>]*>\s* (?<value>.*?) \s* </b>\s* it worked for some lines and some its giving the out put as <...

emacs, auctex and query-replace strings with newline

I use emacs+auctex and auto-fill-mode. Now sometimes I want to search (and replace) a string containing spaces like "test1 test2". The problem is, that auto-fill-mode replaces space-characters sometimes by newline characters. So search and replace of "test1 test2" does not find those occurrences of this string where auto-fill replaced ...

Regex and date matching

Hi I want to search for all possible dates in a string using Regex. In my code i have this: String dateSearchPattern = @"(?<Day>\d{2}).(?<Month>\d{2}).(?<Year>\d{4})|(?<Day>\d{2}).(?<Month>\d{2}).(?<Year>\d{2})"; // date format: dd.mm.yyyy or d.m.yyyy or dd.mm.yy or d.m.yy String searchText = "20.03.2010.25.03.10"; Regex.Matches(sea...

Loose telephone regex validation

I've been trying to find a validation regex to do some loose validation on phone numbers. I'm going to strip some of the stuff out when I use them, but I would like to allow the user the freedom to enter their number as they want, and I want to display it as they have entered it. I figured that the best thing to do is whitelist my chara...

Parsing XML files with regular expressions (Perl)

Hi, I am using regular expression to parse XML file (though regexp is not recommended for xml parsing, but i have to use regexp, no other go). My doubt is how to skip commented lines in XML file, while parsing using Perl. I want Perl to parse XML file, while skipping commented lines. Can anyone help me, please. Thanks Senthil . ...

PHP REGEX: Get Image from URL

What I want If the URL in the string contains a .jpg at the end of the URL (not the string) then it should make an image from it with preg_replace else make a normal link. so for example: If I have http://www.example.com/images/photo.jpg then it should replace with: <img src="http://www.example.com/images/photo.jpg" alt="http://ww...

Python: best/efficient way of finding a list of words in a text?

hi, I have a list of approximately 300 words and a huge amount of text that I want to scan to know how many times each word appears. I am using the re module from python: for word in list_word: search = re.compile(r"""(\s|,)(%s).?(\s|,|\.|\))""" % word) occurrences = search.subn("", text)[1] but I want to know if there is a m...

find string match

I need to check a variable to see if the string starts with http:// or https:// if it exists do something else do another. How would I go about doing that? ...

JavaScript regex to replace a character ignoring HTML tags

Hello everybody, Once again, I need some help and I appreciate you all for being here willing to help. I'm trying to implement a regex for a JavaScript function that will replace a string of text contained in an HTML tag, but ignoring the tag altogether. For example: The string I need to find and replace is the dollar sign ($), and the H...

splitting a simple maths equation regular expression

hi, i am trying to have a regular expression split on equations like 1.5+4.2*(5+2) with operators - + * / so the output would be input into a array so i can parse individually [0]1.5 [1]+ [2]4.2 [3]* [4]( [5]5 [6]+ [7]2 [8]) i have found out that the \b will work on 1+2+3 however if i were to have decimal points it would not split. i...

jQuery-keyfilter plugin

How would I use the keyfilter plugin and allow everything except < and > http://code.google.com/p/jquery-keyfilter/ ...

how to convert ereg_replace in clean MS Word function to preg_replace?

I found this function to clean MS Word markup: $html = ereg_replace("<(/)?(font|span|del|ins)[^>]*>","",$html); $html = ereg_replace("<([^>]*)(class|lang|style|size|face)=(\"[^\"]*\"|'[^']*'|[^>]+)([^>]*)>","<\\1>",$html); $html = ereg_replace("<([^>]*)(class|lang|style|size|face)=(\"[^\"]*\"|'[^']*'|[^>]+)([^>]*)>","<\\1>",$html); an...

Using Regex in MySQL WHERE clauses under specific conditions

Essentially, I'm working on a PHP-Based CMS and I'm looking to add an additional layer of security for the plugin infrastructure. Currently authors must secure their SQL clauses using traditional means, which is no problem. The CMS accepts queries in seperate parts, and the WHERE clause is one part. As an added layer of security, what I...

find lines containing "^" and replace entire line with ""

I have a file with a string on each line... ie. test.434 test.4343 test.4343t34 test^tests.344 test^34534/test I want to find any line containing a "^" and replace entire line with a blank. I was trying to use sed: sed -e '/\^/s/*//g' test.file This does not seem to work, any suggestions? ...

Finding Regex Pattern after doing re.findall

Hi This is in continuation of my earlier question where I wanted to compile many patterns as one regular expression and after the discussion I did something like this REGEX_PATTERN = '|'.join(self.error_patterns.keys()) where self.error_patterns.keys() would be pattern like : error: : warning: cc1plus: undefine reference to Fa...

Hashtag RegEx for SQL query

So I am trying to incorporate a hashtag search into posts on my application. I have come up with a few close Regular Expressions, but none seem to work. Let's say I have a string: #i keep #hashtags in my mom&#39;s attic. She says I am her number #1 son. Why I&#39;m not num#ber #2: http://pics.com/pic#thepic I would want the RegEx to m...

Stripping some characters out of a string

I try to remove some non-safe characters from a string but i believe i have a problem on my RegExp object. What i try to do below is if there are chars whose encoded length is greater than 3 chars they should be replaced with a space. So if encoded value is %3D which is = sign, it is ok to have in my string. But if it is an ’ apostroph...

How to use php preg_replace to replace HTML tags

I'd like to change <pre> with <code> and </pre> with </code>. I'm having problem with the slash / and regex. ...

Object propert is an integer, have to use regex to clean input, looking for good style

I have some text that looks like: California(2342) My object has a property that I need to assign the value 2342 to. I'm looking for input on how to go about doing this, and guarding against any potential for errors in the input. c = SomeClass() c.count = re.compile(r'(\d*)').groups[0] Does that look ok? Or should I do an IF sta...