regex

How do I match a string that does not contain X with ColdFusion regular expressions?

I asked this question earlier, but it got a negative vote, so I'm rewording it. I have: <cfset myExpression = "X"> #REFind(myExpression,myString)# I need to change myExpression so that it returns a value other than zero if there is NOT an X in myString, and a 0 if there is an X in myString. ...

Regex to parse C/C++ functions declarations

I need to parse and split C and C++ functions into the main components (return type, function name/class and method, parameters, etc). I'm working from either headers or a list where the signatures take the form: public: void __thiscall myClass::method(int, class myOtherClass * ) I have the following regex, which works for most fu...

Need Assistance Parsing HTML With PHP

Hello All I am "attempting" to scrape a web page that has the following structures within the page: <p class="row"> <span>stuff here</span> <a href="http://www.host.tld/file.html"&gt;Descriptive Link Text</a> <div>Link Description Here</div> </p> I am scraping the webpage using curl: <?php $handle = curl_init(); ...

Get element by id with regex

Hi, I had a quick question regarding RegEx... I have a string that looks something like the following: "This was written by <p id="auth">John Doe</p> today!" What I want to do (with javascript) is basically extract out the 'John Doe' from any tag with the ID of "auth". Could anyone shed some light? I'm sorry to ask. Full story: I ...

How do I create a regular expression to negate a string but include anything else.

I'm trying to create a regex for apache that will ignore certain strings, but will use anything else. Ive tried many different methods however i just can't seem to get it correct. for example i want it to ignore ignore.mysite.com but anything else i want it to use *.mysite.com ...

Javascript -- get only the variable part of a regex match

given: var regexp = new RegExp("<~~include(.*?)~~>", "g"); What's the easist way in javascript to assign a variable to whatever's matched by .*? I can do this, but it's a little ugly: myString.match(regexp).replace("<~~include", "").replace("~~>", ""); ...

Using preg_replace/ preg_match with UTF-8 characters - specifically Māori macrons

I'm writing some autosuggest functionality which suggests page names that relate to the terms entered in the search box on our website. For example typing in "rubbish" would suggest "Rubbish & Recycling", "Rubbish Collection Centres" etc. I am running into a problem that some of our page names include macrons - specifically the macron ...

Regex: Determine if two regular expressions could match for the same imput?

I want to find out if there could ever be conflicts between two known regular expressions, in order to allow the user to construct a list of mutually exclusive regular expressions. For example, we know that the regular expressions below are quite different but they both match xy50: '^xy1\d' '[^\d]\d2$' Is it possible to determine, us...

Finding start and end tags in string using regex

I am trying to parse an HTML file ( non strict one) using JavaScript my output should be the same HTML file, but I need to process the internal content of any <script></script> tag. I have a method processScript(script) that does that.. I can assume that there will be no <script/> tags. I have a pretty clear idea how to it using just ...

Javascript replace() regex by index number

I have the following string and regex: var string = "Dear [to name], [your name] has decided to share this [link]"; var patt = /\[+[A-Za-z0-9]+\]/; I want to be able to change each of the bracketed variables with dynamic input. How would I use match() or replace() to target the 1st, 2nd and 3rd occurrences of this regex? EDIT: At th...

SQL to select rows that match a URL with wildcard

I have a table in the db with one column containing a URL like http://site.com/users/*/profile I am given a URL (like http://site.com/users/234/profile) and want to select all the rows in the db that match the url (in this case * is a wildcard). I was thinking of using Regex to do this, by replacing the * with regex for any character....

How to find all occurrences of one string in another in JavaScript?

I'm trying to find the positions of all occurrences of a string in another string, case-insensitive. For example, given the string: I learned to play the Ukulele in Lebanon. and the search string le, I want to obtain the array: [2, 25, 27, 33] Both strings will be variables - i.e., I can't hard-code their values. I figured that th...

How to add string object's value into JS regular expression?

var foo = "blaa"; var regex = /foo/i; results in /foo/i instead of /blaa/i. ...

JavaScript regex: find non-numeric character

Let's say I have these two strings: "5/15/1983" and "1983.05.15". Assume that all characters in the string will be numeric, except a "separator" character that can appear anywhere in the string. There will be only one separator character; all instances of any given non-numeric character in the string will be identical. How can I use reg...

How to match the numeric value in a regular expression?

Okay, this is quite an interesting challenge I have got myself into. My RegEx takes as input lines like the following: 147.63.23.156/159 94.182.23.55/56 134.56.33.11/12 I need it to output a regular expression that matches the range represented. Let me explain. For example, if the RegEx receives 147.63.23.156/159, then it needs to ...

regex tutorials or books

Hello, gcc 4.4.4 c89 Does anyone know of any good online tutorials using regex in c. I have to do a lot of regex, which I haven't done before. If the tutorials or books could be related to sscanf would be even better. Many thanks, ...

Get contents of the URL and display links

Hi, I want to get contents of a URL and display only the links present on that page. Please help. Thanks ...

Help with Regular expression (PHP, preg_replace)

I need to do a preg_replace on all of the PHP tags in a string, as well as any characters sitting between the PHP tags. Eg, if the file contents was: Hey there! <?php some_stuff() ?> Woohoo! All that should be left is: Hey there! Woohoo! Here's my code: $file_contents = file_get_contents('somefilename.php'); $regex = '#([<?php](....

problem with java split()

I have a string: strArray= "-------9---------------"; I want to find 9 from the string. The string may be like this: strArray= "---4-5-5-7-9---------------"; Now I want to find out only the digits from the string. I need the values 9,4, or such things and ignore the '-' . I tried the following: strArray= strignId.split("-"); bu...

C#: Adding data to dictionary

I have a list like List<string> TempList = new List<string> { "[66,X,X]", "[67,X,2]", "[x,x,x]" }; I need to add data to the dictionary from the above list Dictionary<int, int> Dict = new Dictionary<int, int>(); so the Dict should contain Key --> 66 value --> 67 i need to take 66(first value) from first string([66,X,X]) and 67(f...