regex

True definition of an English word?

What would be the best definition of an English word? What are the other cases of an English word than just \w+? Some may include \w+-\w+ or \w+'\w+; some may exclude cases like \b[0-9]+\b. But I haven't seen any general consensus on those cases. Do we have a formal defintion of such? Can any of you clarify? (Edit: broaden the questi...

Regexp to simplify Yahoo Answers Feed Title

Hello, I am trying to parse the yahoo answers feed - http://answers.yahoo.com/rss/allq The issue is that the titles have [ Category ] : Open Question : in every title that I do not want... I want to write a regexp to remove this... anything that we can make to remove all the letters in the starting [ and the first : should do it. t...

JS/Jquery/RegEx - Remove all tags except the ones with classname XYZ

Hi everybody, this is driving me nuts ;-) I have a string whith various span tags... I want to remove all span tags except the ones with classname XYZ... The problem is that i havent found a solution to leave the closing tag... My starting point is this regex: text = text.replace(/<\/?[^>]+(>|$)/g, ""); But everything i tried to sa...

How to do regex in following Data using PHP

// [ { "id": "715320" ,"t" : "500268" ,"e" : "BOM" ,"l" : "15.55" ,"l_cur" : "Rs.15.55" ,"ltt":"3:59PM IST" ,"lt" : "Sep 9, 3:59PM IST" ,"c" : "+1.69" ,"cp" : "12.19" ,"ccol" : "chg" } ] I need to Get each with name and assign the value to each Like $id=715320; $e=BOM; from above data, how can i do that? ...

Regular Expression related: first character alphabet second onwards alphanumeric+some special characters

Hi, I have one question related with regular expression. In my case, I have to make sure that first letter is alphabet, second onwards it can be any alphanumeric + some special characters. Regards, Anto ...

PHP Search for string then get next characters

Hello, I have a string that looks like this: blah blah blah Team ID:</div>xxxxxxx blah blah blah where the x's are a 7 digit number. How can I search for the "Team ID:" and then get the 7 digit number ahead of it? (In php). ...

Regex Pipe bar question in PHP

I have a line of text that looks like "...X...Y...", where X and Y are both either Ok, Empty, or Open. Using PHP, I'm trying to use preg_match() to figure out what each one is. $regex = '/(Ok|Open|Empty)/'; preg_match($regex, $match, $matches); print_r($matches); However, in the case that X is "Empty", and Y is "Ok", the following li...

Help with HtmlAgilityPack, match 2 different nodes with each other.

Im a little stuck with my app again. My app retrieves "Place names" and their "Addresses" from yellowpages.ca Here is the code so far: Dim content As String = "" Dim web As New HtmlAgilityPack.HtmlWeb Dim doc As New HtmlAgilityPack.HtmlDocument() doc.Load(WebBrowser1.DocumentStream) Dim hnc As HtmlAgilityPack.HtmlN...

What does this regex pattern describe: ".{5,}+"

One of the HTML input fields in an app I'm working on is being validated with the following regex pattern: .{5,}+ What is this checking for? Other fields are being checked with this pattern which I also don't understand: .+ ...

How can I use regex to solve this?

I have two strings that I need to pull data out of but can't seem to get it working. I wish I knew regular expression but unfortunately I don't. I have read some beginner tutorials but I can't seem to find an expression that will do what I need. Out of this first string delimited by the equal character, I need to skip the first 6 charac...

find match then include everything to the end of the line

How would I match 'ber' to the end so it picks up 'ber/sunday/wednesday' monday/october/sunday/wednesday ...

Regular expression puzzle

This is not homework, but an old exam question. I am curious to see the answer. We are given an alphabet S={0,1,2,3,4,5,6,7,8,9,+}. Define the language L as the set of strings w from this alphabet such that w is in L if: a) w is a number such as 42 or w is the (finite) sum of numbers such as 34 + 16 or 34 + 2 + 10 and b) The number ...

Splitting and assigning a string with whitespace as the delimeter

Hello, I need help splitting this string, but i can't seem to come with the right way of doing it. Suppose I have two numbers on a line 12 101 I would like to take the first and assign it to variable, and then take the second and assign it to a variable, this may sounds easy, but for me i can't come up with the right way to do it? ...

why does ^[a-zA-Z][\w.,\$;]{0,6}$ takes part of abc!

Why does ^[a-zA-Z][\w.,\$;]{0,6}$ match the abc part of the string abc! and not outright reject it? ...

Help with capturing with regexp

I have this list: foo chef.rb baz bar cucumber.rb bar baz gem.rb foo I want to capture all the names without .rb. My current regexp looks like this: /([^\s](?:.)*?.(?:rb))/i But it captures the .rb too. How do I capture just the base name? Thanks. ...

How does this regex replacement reverse a string?

This is the fourth part in a series of educational regex articles. It show how the combination of nested reference (see: How does this regex find triangular numbers?) to "count" within assertions (see: How can we match a^n b^n with Java regex?) can be used to reverse a string. The programmatically generated pattern uses meta-pattern a...

Having problems with regular expressions with preg_split in PHP

I have the following input: a few words - 25 some more - words - 7 another - set of - words - 13 And I need to split into this: [0] = "a few words" [1] = 25 [0] = "some more - words" [1] = 7 [0] = "another - set of - words" [1] = 13 I'm trying to use preg_split but I always miss the ending number, my attempt: $item = preg_split("...

Find First Word matching from Given Text - Regex

I want to find First Word matching from Given Text and replace with another word, using Regex. Consider following string as an Example Text Which type is your item? i suppose that the item isn't a string, if so you can override ToString() method in the item class and use the jayant's code. I want to search first "item" w...

How can I make a regular expression which takes accented characters into account?

I have a JavaScript regular expression which basically finds two-letter words. The problem seems to be that it interprets accented characters as word boundaries. Indeed, it seems that A word boundary ("\b") is a spot between two characters that has a "\w" on one side of it and a "\W" on the other side of it (in either order), ...

What does it mean when a regular expression is surrounded by @ symbols?

Question What does it mean when a regular expression is surrounded by @ symbols? Does that mean something different than being surround by slashes? What about when @x or @i are on the end? Now that I think about it, what do the surrounding slashes even mean? Background I saw this StackOverflow answer, posted by John Kugelman, in ...