regex

PHP Fomatting Regex - BBCode

To be honest, I suck at regex so much, I would use RegexBuddy, but I'm working on my Mac and sometimes it doesn't help much (for me). Well, for what I need to do is a function in php function replaceTags($n) { $n = str_replace("[[", "<b>", $n); $n = str_replace("]]", "</b>", $n); } Although this is a bad example in case someo...

string parsing help

I've got a string like this: #################### Section One #################### Data A Data B #################### Section Two #################### Data C Data D etc. I want to parse it into something like: $arr( 'Section One' => array('Data A', 'Data B'), 'Section Two' => array('Data C', 'Data D') ) At first I tri...

regex numeric data processing: match a series of numbers greater than X

Say I have some data like this: number_stream = [0,0,0,7,8,0,0,2,5,6,10,11,10,13,5,0,1,0,...] I want to process it looking for "bumps" that meet a certain pattern. Imagine I have my own customized regex language for working on numbers, where [[ >=5 ]] represents any number >= 5. I want to capture this case: ([[ >=5 ]]{3,})[[ <3 ]]{2...

Conditional regex in vim?

Is it possible to do conditional regex (like the one described in http://www.regular-expressions.info/conditional.html) in Vim? ...

Match d-M-Y with javascript regex how?

Hi, my date formatting in PHP is d-M-Y and I'm trying to match the dates with a javascript regex: s.match(new RegExp(/^(\d{1,2})(\-)(\w{3})(\-)(\d{4})$/)) To be used with the jQuery plugin, tablesorter. The problem is it's not working and I'm wondering why not. I tried removing the dashes in my date() formatting (d M Y) and tried the...

Regex issue in rewriter config

I'm having an issue with bad requests from certain search parameters. An example URL: http://www.foo.com/washington/forums/search/%26 Results in a bad request. The rewriter config line looks like this: <rewrite url="^(.*)/forums/search/(.*)" to="~/Pages/Forums/Overview.aspx?Address=$1&amp;q=$2" processing="stop" /> I'm thinking it...

[AS 3.0] How to use the string.match method to find multiple occurrences of the same word in a string?

In Actionscript and Adobe Flex, I'm using a pattern and regexp (with the global flag) with the string.match method and it works how I'd like except when the match returns multiple occurrences of the same word in the text. In that case, all the matches for that word point only to the index for the first occurrence of that word. For exam...

Ignoring a character along with word boundary in regex

I am using gsub in Ruby to make a word within text bold. I am using a word boundary so as to not make letters within other words bold, but am finding that this ignores words that have a quote after them. For example: text.gsub(/#{word}\b/i, "<b>#{word}</b>") text = "I said, 'look out below'" word = below In this case the word below...

MS 70-536 .NET Framework Foundation - info on Exam? Especially regex?

Hi, I know there are already some questions about this, but not that specific. I have the self-paced training kit and worked through the test exam tool that is on the CD coming with the book. I constantly fail on the test tool, mostly on the regex questions. I'm not a regex guru. In fact my regex-fu is more than weak. I know what regex...

python: multiline regular expression

Hi, everyone I have a piece of text and I've got to parse usernames and hashes out of it. Right now I'm doing it with two regular expressions. Could I do it with just one multiline regular expression? #!/usr/bin/env python import re test_str = """ Hello, UserName. Please read this looooooooooooooooong text. hash Now, write down this ...

Regular expression for email

Possible Duplicate: What is the best regular expression for validating email addresses? I tried the reg expression ^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+ for the email validation. Since I want the user to allow submitting even with the empty email address. So I changed the reg ex to (^([a-zA-Z0-9_.-]...

groovy regexpression

Hi, How to get file name from these lines using groovy . File file = new File(SOURCE_FILE_NAME).eachLine{line-> println line } getting line like this : /usr/local/ /usr/local/testing.groovy /usr/local/picture.jpg expecting output: testing.groovy picture.jpg thanks ...

User-Agent parsing using c#

Hello, I have a large list of User-agent strings. For the analytic panel i need to parse them and split to: Browser name, version. 2.Platform name, version If there is a ready solution or code to do this? Like there: http://useragentstring.com/ ...

Reverse regular expressions to generate data

In one of the StackOverflow Podcasts (the one where guys were discussing data generation for testing DBs -- either #11 or #12), Jeff mentioned something like "reverse regular expressions", which are used exactly for that purpose: given a regex, produce a string which will eventually match said regex. What is the correct term for this wh...

Visual Studio's Format Document – How to Write it in C#

I'm having a go at writing some C# code which overrides the Render method of the System.Web.UI.Page and then reformats the HTML before presenting it to the browser. This is purely experimental so overhead is not a concern right now. I'm perhaps a little learned in the ways of the regular expression and would like to utilise them here, b...

Percentage position move

Is there a simple way to move percentage pointer after the value: 120 @ %60 {a} >> 120 @ 60% {a} ...

PHP regex:Find all 6 digit numbers in a string that do not end in 00

Hello all I'm trying to find all the 6 digit numbers in a string that do not end in 00. Something like that /([0-9]{4})([^00])/ //i know this is wrong so the string asdfs dfg_123456_adsagu432100jhasj654321 will give me results=[123456,654321] and not 432100 Thanks Have a good day ...

Regex for finding an unterminated string

I need to search for lines in a CSV file that end in an unterminated, double-quoted string. For example: 1,2,a,b,"dog","rabbit would match whereas 1,2,a,b,"dog","rabbit","cat bird" 1,2,a,b,"dog",rabbit would not. I have very limited experience with regular expressions, and the only thing I could think of is something like "[^"]*...

How can I detect and split words like "Apple 1 & 2" into "Apple 1" and "Apple 2" from a list?

...

Is it possible to have regexp that matches all valid regular expressions?

Is it possible to detect if a given string is valid regular expression, using just regular expressions? Say I have some strings, that may or may not be a valid regular expressions. I'd like to have a regular expression matches those string that correspond to valid regular expression. Is that possible? Or do I have use some higher level ...