regex

Regex matching items following a header in HTML

What should be a fairly simple regex extraction is confounding me. Couldn't find a similar question on SO, so happy to be pointed to one if it exists. Given the following HTML: <h1 class="title">Title One</h1><p><a href="#">40.5</a><a href="#">31.3</a></p> <h1 class="title alternate">Title Two</h1><p><a href="#">12.1</a><a href="#">8...

Extracting information out of a column with regexs in MySQL

Hello, Is it possible to get the (first?) match of a regex and output it within a select? It looks like the REGEXP function only return whether there has been a match or not. I want to be able to extract information out of a varchar column without having to use complex SUBSTRING-LOCATION nestings. Any ideas? ...

Regex - Replace when group contains multiple captures

I am having trouble trying to get some replaces working with my regex. Here is some sample data I'm working with : $/Data: $One $Two $/New: $Four $Five Here is the result I'd like to obtain : $/Data/One $/Data/Two $/New/Four $/New/Five Currently, I'm using this regex : (\$/.*?):\r\n(?:(?:\$(.*)\r\n)*)+ This allows me to captur...

What is the regular expression for the following strings and would the expression change if the number rolled over?

What would be the following regular expressions for the following strings? 56AAA71064D6 56AAA7105A25 Would the regular expression change if the numbers rolled over? What I mean by this is that the above numbers happen to contain hexadecimal values and I don't know how the value changes one it reaches F. Using the first one as an exa...

javascript window.event coming up null ?

I am using a CustomValidator in ASP.NET as follows: <asp:CustomValidator ID="cvComment" ControlToValidate="txtComment" Display="None" EnableClientScript="true" ClientValidationFunction="validateComment" runat="server" ></asp:CustomValidator> And this is the function that gets called: function validateComment(source, args)...

ASP.Net RegularExpressionValidator fires if string contains \n or is longer than 250 chars

What is the regular expression for a RegularExpressionValidator so it fires if the string in the validated control contains a \n, \t or is longer then 250 chars? ...

Regex - negative look-ahead assertion

Hi, I wand to replace URLs like www.example.com/profile/USERNAME by [user]USERNAME[/user] BBCode! $userURLSearch = "#((https?|ftp)://|www\.)example\.com/profile/([A-Za-z][A-Za-z0-9_-]+)(?!/)#i"; $userURLReplace = "[user]\\3[/user]"; $text = preg_replace($userURLSearch, $userURLReplace, $text); But it also transforms URLs like www.ex...

Multi-line regular expressions in Visual Studio

Is there any way to get Visual Studio to perform a regex replace across multiple lines (let the match cross line boundaries)? I know there are many editors I can use for this, but it seems strange that this feature has been left out of Visual Studio. Am I missing something? ...

Regular expression for numbers

Hi, I need a regular expression to detect at least one number in a string. Other characters can be anything. Please help me to implement this in objective C. Regards, Dilshan ...

GUI CSS parser/editor for link colors

Given a stylesheet with various rules, some of them being for hyperlinks, I would like to present each rule (only those containing "a" tags) along with the current value for "color" to allow the end user to click on a colorpicker widget and change the color. Using jQuery Ajax with PHP to save the updated color back to the stylesheet. Fo...

Problem with simple regex

Hi all, I have the following regular expression in a validation rule: ^[a-zA-Z0-9',!;?~>+&\"\-@#%*.\s]{1,1000}$ However, I can enter ====== which I believe should not be allowed. My thoughts is that somehow the - could cause trouble if not properly escaped or something but this is way over my head. ...

[PHP] cURL and redirects - returning multiple headers?

I'm writing a specialized PHP proxy and got stumped by a feature of cURL. If the following values are set: curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true ); curl_setopt( $ch, CURLOPT_HEADER, true ); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); cURL correctly handles redirects, but returns ALL page headers, not just the final (no...

Regex to match email and query string

Hello, The following REGEX does not match the query string in URLs and e-mails. For everything else it works brilliantly. Samples that need to be matched [email protected] and abc.com/index.php?test=true and abc.com?test=true The regex is below: ((?#Protocol)(?:(?:ht|f)tp(?:s?)\:\/\/|~\/|\/)?(?#Username:Password)(?:\w+:\w+@)?(?#Subdoma...

Matching html input values with regex

I am trying to match a string like the following: <input type="text" value="cbyEOS56RK3lOxtiCrhmWSkDuNWwrFN4" name="iden"> This is my code: $pattern = '~value="(.+?)" name="iden"~'; preg_match($pattern, $page, $match); print_r($match); As you can probably see, I am trying to match the value in this HTML input. By what I know of reg...

Dirt-simple PHP templates, continued

Background So, last time I inquired about PHP templates, I got a lot of responses like: it isn't needed; PHP is a good enough templating language on its own. it's hard to develop a templating language that is both powerful and easy for designers to work with (or around). it's already been done, use templating framework X. you're st...

PHP preg_replace to turn **xyz** to <b>xyz</b>

I decided to, for fun, make something similar to markdown. With my small experiences with Regular Expressions in the past, I know how extremely powerful they are, so they will be what I need. So, if I have this string: Hello **bold** world How can I use preg_replace to convert that to: Hello <b>bold</b> world I assume some...

Can someone explain this strange mod_rewrite regex behavior

I've been working on a script for debugging mod_rewrite, and when testing their regex system I've had some strange results. I'm wondering if this is normal behavior for the mod_rewrite regex engine or if some part in my code is causing it. Requested URL: http://myurl.com/path/to/something .htaccess has: RewriteRule to where Using my d...

how to paste the "backslash-dot" (\.)combo in R?

as title, I am working on some gregexpr in R now, I need to search for something start with a dot, so I need to use "." (without quote), but R keep saying that it is an unrecognized escape. What can I do? Thanks! ...

c# Regex for list Parsing

I have a text field that accepts user input in the form of delimeted lists of strings. I have two main delimeters, a space and a comma. If an item in the list contains more than one word, a user can deliniate it by enclosing it in quotes. Sample Input: Apple, Banana Cat, "Dog starts with a D" Elephant Fox "G is tough", "House" Desi...

Disable all checkstyle checks for a specific java package

Hi I have two packages namely com/mydomain/abc/delegate/xyz/jaxws/managed and com/mydomain/abc/xyz/jaxws/managed I require checkstyle to be disabled only for the second package as these holds proxy classes that are autogenerated. I use a suppression.xml as shown below <?xml version="1.0"?> <!DOCTYPE suppressions PUBLIC "...