regex

Check a phrase is not in an <a> (or other) element

A friend is writing an advertisement script that puts links around select phrases in HTML code. Naturally if the phrase is already inside an <a> element (or another element that doesn't allow it - like if the phrase is found in the attribute of an element), he doesn't want the script to write out a link as it would break validation. H...

How can I use Perl to validate this data containing balanced text?

I have a text file filled with sentences with unique pattern. The unique pattern is: NAME [ e_NAME ] simple rule: the "NAME" must follow after "e_" if the "e_" appearers inside the brackets! The problem comes out when the string is complicated. I'll show the end point situations that may be hard to analyse: Lines that won't match...

Need help with (hopefully) simple RegEx

I am brand new to using RegEx's and need a bit of a jump start to get the ball rolling. The RegEx I need is, hopefully, pretty simple. All it needs to do is verify that the text entered follows the following format: 00.000 (2 digits, a period, 3 digits). Any advice on the the RegEx itself and how to implement would be greatly appreci...

Regex Proxy Server

I control access via a proxy server and run some regex on every request. For prototype I have used curl, regex and php. Obviously this won't put up with any serious load. Can anyone suggest and proxy servers that would be suitable? ...

Iterative regex matching

We've become fairly adept at generating various regular expressions to match input strings, but we've been asked to try to validate these strings iteratively. Is there an easy way to iteratively match the input string against a regular expression? Take, for instance, the following regular expression: [EW]\d{1,3}\.\d When the user ent...

Why doesnt Regex.Match have a GetEnumerator function?

Regex.Match has a .Success and .NextMatch why doesnt it have a GetEnumerator function? With my logic it seems easy enough to implement. But it isnt in 3.5 so can anyone tell me why not? foreach (var m in Regex.Match("dummy text", "mm")) error CS1579: foreach statement cannot operate on variables of type 'System.Text.RegularExpressions...

Regular Expression or Database for Check if String is Person's Name?

I have an application that reads XML information about a vehicle title and parses it into my application. In my database, I always store my names according to whether it is an individual's name or a company's name(because that can occur in my system). The trouble is that the XML source has name data, but it does not specify if it is an...

php regular expression to filter out junk

So I have an interesting problem: I have a string, and for the most part i know what to expect: http://www.someurl.com/st=???????? Except in this case, the ?'s are either upper case letters or numbers. The problem is, the string has garbage mixed in: the string is broken up into 5 or 6 pieces, and in between there's lots of junk: unpri...

Regular expressions performance: Boost vs. Perl

I'm looking for a performance comparison between perl and boost regular expression. I need to design a piece of code which relies very heavily on regular expressions, and can choose between: running it through a boost regex dispatching a perl interpreter and do the work in perl I know perl is known for it's optimized string pro...

I found this "[\\?&]v=([^&#]*)" on the internet can someone explain it to me.

I found a method on the internet that can retrieve the Id of a youtube video from the url. this is it. var vid; var results; results = url.match("[\\? vid = ( results === null ) ? url : results[1]; The Id will be contained in "vid". What I don't understand and I find interesting and want to know is this. results = url.match("[\\?...

Is regex the right tool to find a line of HTML?

I have a PHP script that pulls some content off of a server, but the problem is that the line on which the content is changes every day, so I can't just pull a specific line. However, the content is contained within a div that has a unique id. Is it possible (and is it the best way) for regex to search for this unique id and then pass th...

can you get me * out aaa.*.domain.com using regex ?

Hi, No matter how hard I try I can't get this.. This matches the whole domain only when it's format is aaa.bbb.ccc . ^[^.]+\.[^.]+\.[^.]+$ Our domain name is static (domain.com). So this needs to select * out aaa.*.domain.com. aaa may or may not be there. Thanks! ps: sorry for aaa part being unclear. it's another unknown. so it i...

regex to remove last line of block of text ..

Hi , how do i remove the last line from a block of text in java script without using loops.(only using regex) eg., "The Internet is a global system of interconnected computer networks that use the standard Internet Protocol Suite (TCP/IP) to serve billions of users worldwide. It is a network of networks that consists of millions of pri...

match pattern in javascript

How can i match a expression in which first three characters are alphabets followed by a "-" and than 2 alphabets. For eg. ABC-XY Thanks in advance. ...

Mod Rewrite ignoring -d

After a day or two, I am still fighting with Mod Rewrite. It seems that 60% of my development time is spent battling the server. My current URL structure is such that all http://example.com/xyz and http://example.com/xyz/abc should be handled by index.php. The problem is I have a http://example.com/admin/ section, which is a real direct...

Will this regular expression ^[^\s]+$ prevent SQL injection? if No how to get around the restriction?

used to check user input like username not a login account. ...

php getting part of a url into a sting

This question is more of a "what is the best/easiest way to do this type of question. I would like to grab just the users id from a string such as <a href="/profile.php?rdc332738&amp;id=123456&amp;refid=22">User name</a> I would like to parse the string and get just the "123456" part of it. I was thinking I could explode the string but...

Replace the line containing the Regex

Hi, I have an input string containing multiple lines(demarcated by \n). I need to search for a pattern in the lines and if its found, then replace the complete line with empty string. My code looks like this, Pattern p = Pattern.compile("^.*@@.*$"); String regex = "This is the first line \n" + "And this is second ...

regex to wrap img tag with href containg the src

[Edited - Sorry Bart] I've looked at other answers but struggling to match this. I want to wrap an image tag where the src is the second attribute (after title) with a specific anchor tag that contains a link to the image found in the src from the image tag. Example of img tag in string. This has been entered via tinymce wysiwyg and al...

Regular expression required

Please give me one regular expression which mathes these kind of name formats like: 1) M/S.KHALIL WARDE S.A.L. 2) Oliver Twist The expression should allow alphabets, dot, space and / only. thanks ...