regex

Regular Expression for numerical constant

In Sipser's book of Theory of computation, following is given : a numerical constant that may include a fractional part and/or a sign may be described as a member of the language ( + U - U e) (D+ U D+ . D* U D* . D+) where D = {0,1,2,3,4,5,6,7,8, 9} is the alphabet of decimal digits. Examples of generated strings are: 72, 3.14159,...

Javascript regex not working in IE

So I've got this table being generated and each cell is given a unique id which is r#c# where the # is the row/column. I've got the code below that extracts the row number and column number from the ID of the cell on mouseover, and it works just fine in firefox and chrome, but does not work in internet explorer. var cell_id = $(this).a...

Reg Ex Django Url Conf

These is my django URLconf: urlpatterns = patterns('', ('^hello/$', hello), (r'^polls/$', 'mysite.polls.views.index'), (r'^polls/(?P<poll_id>\d+)/$', 'mysite.polls.views.detail'), (r'^polls/(?P<poll_id>\d+)/results/$', 'mysite.polls.views.results'), (r'^polls/(?P<poll_id>\d+)/vote/$', 'mysite.polls.views.vote'), ...

regular expression for anything but an empty string in c#

Hi, Is it possible to use a regular expression to detect anything that is NOT an "empty string" like this: string s1 = ""; string s2 = " "; string s3 = " "; string s4 = " "; etc. I know I could use trim etc. but I would like to use a regular expression. Thanks. Christian ...

how to replace all instances of a sub string in a string

Hi, I'm trying to work with RegEx to split a large string into smaller sections, and as part of this I'm trying to replace all instances of a substring in this larger string. I've been trying to use the replace function but this only replaces the first instance of the substring. How can I replace al instances of the substring within the...

Javascript Regular Expression for Password

I am writing the regex for validating password in Javascript. The constraints are: Password must contain at least one uppercase character Password must contain at least a special character With trial and error and some searching on the net, I found that this works: /(?=.*[A-Z]+)(?=.*[!@#\$%]+)/ Can someone please explain the part ...

Find all elements based on ids using regex on jquery selector

Hi, I've got several elements with unique ids like so: <div id='item-1-top'></div> <div id='item-2-top'></div> <div id='item-3-top'></div> I was hoping that the following would work using jquery: $("#item-[.]+-top").each(function() { $(this).hide(); }); I've not got a good grasp of regex and would appreciate some input please as...

Javascript Regex to target and remove a css rule from a style tag, based on its selector?

What would be the regex I could use to completely remove a css rule from an inline stylesheet based on the selector that I provide, via javascript? For example, I get the contents of the style tag and it contains a rule: .some_class { color: #FFF; font-style: italic; } If i provide the selector '.some_class' what is the corre...

Formatting any date into MM/dd/yyyy

Hi I'm currently working on some SSRS reports and the data I am getting comes in quite a range. I'm getting dates in forms of: 6/18/2010 6:00:00 AM, 6/18/2010, 2010/6/18 I was hoping to be able to come up with a formatting code to use for the row so that it would convert any of these into the MM/dd/yyyy format and anything else just lea...

How to match a word that doesn't start with X but ends with Y with regex

Example; X=This Y=That not matching; ThisWordShouldNotMatchThat ThisWordShouldNotMatch WordShouldNotMatch matching; AWordShouldMatchThat I tried (?<!...) but seems not to be easy :) ...

A beginner's guide to interpreting Regex?

Greetings. I've been tasked with debugging part of an application that involves a Regex -- but, I have never dealt with Regex before. Two questions: 1) I know that the regexes are supposed to be testing whether or not two strings are equivalent, but what specifically do the two regex statements, below, mean in plain English? 2) Does a...

abusing ragel, possibly need new approach / tool

Hi, I'm trying to use Ragel to implement a simple yes/no fsm. Unfortunately the language specification consists of the union of about a thousand regular expressions, with * operators appearing once or more in the majority of them. So, the number of possible states explodes and it seems it will be impossible to use Ragel to generate an f...

regex to match RTRIM(LTRIM(xx)) = xx

I am trying to jot down regex to find where I am using ltrim rtrim in where clause in stored procedures. the regex should match stuff like: RTRIM(LTRIM(PGM_TYPE_CD))= 'P')) RTRIM(LTRIM(PGM_TYPE_CD))='P')) RTRIM(LTRIM(PGM_TYPE_CD)) = 'P')) RTRIM(LTRIM(PGM_TYPE_CD))= P RTRIM(LTRIM(PGM_TYPE_CD))= somethingelse)) etc... I am trying...

Trouble with regular expression for comments code

Hey I am currently making a homepage where logged in users can write comments. The comment string is first run through a function that str_replaces emoticons. After that I want it to exchange [url=www.whatever.com]linktext[/url] with: <a href='www.whatever.com'>linktext</a> The reason for this is that I want to strip the text for...

Regular expressions versus lexical analyzers in Haskell

I'm getting started with Haskell and I'm trying to use the Alex tool to create regular expressions and I'm a little bit lost; my first inconvenience was the compile part. How I have to do to compile a file with Alex?. Then, I think that I have to import into my code the modules that alex generates, but not sure. If someone can help me, I...

java.util.regex matching anything before expression

I trying to tokenize following snippets by types of numbers: "(0-22) 222-33-44, 222-555-666, tel./.fax (111-222-333) 22-33-44 UK, TEL/faks: 000-333-444, fax: 333-444-555, tel: 555-666-888" and "tel: 555-666-888, tel./fax (111-222-333) 22-33-44 UK" and "fax (111-222-333) 22-33-44 UK, TEL/faks: 000-333-444, fax: 333-444-555" and ...

Javascript Regular Expression to PHP

I have written this JavaScript that calculate words, but I am unable to convert this JavaScript code to PHP regular expression. Can anyone help me with following code? return str.replace(/\&\w+;/ig,"") .replace(/lt;/g, "<") .replace(/gt;/g, ">") .replace(/(<([^>]+)>)/ig,"") .replace(/^[^A-Za-z0-9-\']+/gi,...

Syntax highlighting for regular expressions in Vim

Whenever I look at regular expressions of any complexity, my eyes start to water. Is there any existing solution for giving different colors to the different kinds of symbols in a regex expression? Ideally I'd like different highlighting for literal characters, escape sequences, class codes, anchors, modifiers, lookaheads, etc. Obviousl...

regex help please

Hello Guys need a quick Regular expression to match the following A-Z a-z 0-9 " - ? . ', ! new lines and spaces Any ideas? ...

Metacharacters and parenthesis in regular expressions

Can anyone elaborate/translate this regular expression into English? Thank you. var g = "123456".match(/(.)(.)/); I have noticed that the output looks like this: 12,1,2 and I know that dot means any character except new line. But what does this actually do? ...