regex

How can I optimize this C# regex? "^\s?([-*]|\d+[.])\s+"

I am not an expert at regular expression and have a regular expression ^\s?([-*]|\d+[.])\s+ I wonder if anyone has ideas about shortening/optimizing/simplifying the above regular expression? ...

Regular Expressions: difference between ^ and \A

Is the only difference between ^ and \A the fact that \A can never match after a line break? (even in multi-line mode) The PCRE man page says: ^ assert start of string (or line, in multiline mode) ... \A matches at the start of the subject Thanks! ...

Mysql: Use REGEX to extract string

I would like to have a mysql query like this: select <second word in text> word, count(*) from table group by word; All the regex examples in mysql are used to query if the text matches the expression, but not to extract text out of an expression. Is there such a syntax? ...

It return false instead of true

How to match "FileNew" in "FileNewABC" which is a value from f_var and return true? newfilename = Pattern.compile("FileNew").matcher(f_var).matches(); It always return false. ...

JavaScript - Validating a Hex in Opera?

Hi, This function works in Firefox, Chrome, IE9. Doesn't work in Opera. function isValidHex(hex) { alert(hex); var strPattern = /^#([0-9a-f]{1,2}){3}$/i; alert(strPattern.test(hex)); return strPattern.test(hex); } The hex going in is the same. The result of strPatter.test returns false in Opera and true in Firefox. Tested. ...

C# ISO 8601 Time Interval validation

Dear all, I have searched for a while and can't seem to find anything that's related to this. I need to validate an ISO 8601 time interval. There is loads of stuff about ISO 8601 date times but i specifically need interval. I am using a regex and this is what I have so far; Regex regEx = new Regex(@"^P((\d+)Y)((\d+)M)((\d+)D)(T)((\d...

Regex question ^[a-zA-Z0-9]{5,10}$

The above regular expression (in Java) matches a string of alpha numeric characters of length between 5 and 10. How can I modify the above regular expression to match with the above requirements as well as matching with an empty string? ...

Testing regular expressions tool (Linux/ubuntu)

Hello, I searched for a question about regexp testing/learning tools, but people usually suggest Windows based solution. I found one for ubuntu: redit. However, I'm wondering if there are better tools for the job. So, without further ado Q: What is the best tool for testing/leadning regular expressions for linux/ubuntu? Sorry if th...

Rexeg - Combining positive and negative lookbehind

I am doing some replaces in some huge SSIS packages to reflect changes in table- and column names. Some of the tabels have columnnames witch are identical to the tablenames and I need to match the columnname without matching the tablename. So what i need is a way to match MyName in [MyName] but not in [dbo].[MyName] (?<=\[)(MyName)(?=...

Classic ASP RegExp small change

Hi, I have some regular expression code that grabs the data between the title tags on a page: <% Function UrlExists(sURL) Dim objXMLHTTP Dim thePage Dim strPTitle Dim blnReturnVal Dim objRegExp Dim strTitleResponse 'Create object Set objXMLHTTP = CreateObject("MSXM...

How to get the nearest and the smallest token before the known one?

I have a string which looks like: "some token","another token","yet another token","Necessary Token","KNOWN TOKEN","next to known token" How to get "Necessary Token" with regular expression from the given string? I tried the next expression: \"(.+)\","KNOWN TOKEN" but it matches the whole substring from the beginning to the...

Using Javascript regular expression for filtering HTML

Good morning is there a clever way to use a javascript regular expression to clean up this string: var spans = "<SPAN><A href="javascript:sel.RemoveProductFromSelection('12372');"><IMG src="remove.gif" width=18> </A>Mirage - JOY</SPAN> <SPAN><A href="javascript:sel.RemoveProductFromSelection('12427');"><IMG src="remove.gif" width=18> <...

PHP - quick regular expression question

Hey, so I am trying to match word in a wall of text and return few words before and after the match. Everything is working, but I would like to ask if there is any way to modify it so it will look for similar words. Hmm, let me show you an example: preg_match_all('/(?:\b(\w+\s+)\{1,5})?.*(pripravená)(?:(\s+){1,2}\b.{1,10})?/u', $item, ...

Confusion regarding regex

Hi, I just found this regex in JavaScript var str=input.replace(/\0/g, "\\0"); Can you please explain me what does it mean? What is the meaning of /\0/g and \\0? ...

PHP function to escape MySQL regexp syntax

I'm looking for something similar to preg_quote, but for the MySQL regexp syntax. Any ideas? ...

Regular expression to replace all ../../ with / URLs to be used in visual studio

I've recently inherited a site created in Dreamweaver where all URLs use the 'up one level' notation e.g. "../products/" and I would like to do a global find and replace with root path e.g. "/products/". What's the regular expression I need to use in the Visual Studio Find & Replace Dialog to replace the following matches: "../../../pr...

UK and Northern Ireland Vehicle Registration Number validator (PHP)

I need a validation function for both UK and NI vehicle registration number. It can be two separate functions too. ...

How can a user upload a résumé in Word or other common format and have it uploaded into my DB in PHP?

How does résumé upload work? I have a site in PHP and right now users can build their résumé line by line, because it is stored in db table. How can a user upload a resume in Word or other common format and have it uploaded into my db? Is it something to do with regex? Are there any scripts out there available that can do that? Just tr...

price regex help

Hi, how to make regex below to detect also prices like just £7 not only everything > 9 /\d[\d\,\.]+/is thanks ...

Problem with fileupload only allowing images

<asp:RegularExpressionValidator id="RegularExpressionValidator1" runat="server" ErrorMessage="Only images are allowed!" ValidationExpression="^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*)) +(.jpg|.JPG|.gif|.GIF|.png|.PNG|.jpeg|.JPEG)$" ControlToValidate="fileUpEx"></asp:RegularExpressionValidator> ...