473,320 Members | 1,719 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

RegEx.. Finding pattern?

80
Hi All!
I'm a little confused by using RegExe in general.
Does anybody know how the pattern would look like if I needed to print out anything in between two known blocks?

The code looks like this:
Expand|Select|Wrap|Line Numbers
  1. <span class=bld>2832.1600 USD</span>
I would need to extract the number 2832.1600

Thanks!
Frederik
Feb 19 '11 #1

✓ answered by Monomachus

Well in general for testing I'd recommend Rubular.com or a Regex Testing tool from Rad Software http://www.radsoftware.com.au/regexdesigner/

extract the number which can be done in many way depending on what exactly you are trying to parse.

See Rubular link for your particular example
http://www.rubular.com/r/GeJRrZS7E1

The pattern is
^<span.*?>(\d*\.\d*).*<\/span>$

Now the explanation
From the start of the line (^ character)
You need to have "<span" characters
Followed by some other characters until the ">" character (it is done by using .*? non greedy technique which takes character after character (?) and sees if it matches)
Now you'll have 0 or more digits followed by a point and than followed by 0 or more digits (\d*\.\d* - it is also saved with the parenthesis)
Followed by 0 or more characters (.*)
Until "</span>" characters
And the line should end here ($ character)

4 2103
Monomachus
127 Expert 100+
Well in general for testing I'd recommend Rubular.com or a Regex Testing tool from Rad Software http://www.radsoftware.com.au/regexdesigner/

extract the number which can be done in many way depending on what exactly you are trying to parse.

See Rubular link for your particular example
http://www.rubular.com/r/GeJRrZS7E1

The pattern is
^<span.*?>(\d*\.\d*).*<\/span>$

Now the explanation
From the start of the line (^ character)
You need to have "<span" characters
Followed by some other characters until the ">" character (it is done by using .*? non greedy technique which takes character after character (?) and sees if it matches)
Now you'll have 0 or more digits followed by a point and than followed by 0 or more digits (\d*\.\d* - it is also saved with the parenthesis)
Followed by 0 or more characters (.*)
Until "</span>" characters
And the line should end here ($ character)
Feb 19 '11 #2
Pheddy
80
Wow! Suddenly made alot more sense.. Thanks that helped alot!
Feb 20 '11 #3
Pheddy
80
Couldn't make any matches with
Expand|Select|Wrap|Line Numbers
  1. ^<span.*?>(\d*\.\d*).*<\/span>$
Please note I use VBScript version 5.8
Feb 22 '11 #4
Pheddy
80
OH I found the problem.. The think Is it is loaded from a HTML source and theres more characters on the entire line wich looks like this:

Expand|Select|Wrap|Line Numbers
  1. <div id=currency_converter_result>320 GBP = <span class=bld>2816.6400 DKK</span> 
Feb 22 '11 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Han | last post by:
Determining the pattern below has got my stumped. I have a page of HTML and need to find all occurrences of the following pattern: score=9999999999&amp; The number shown can be 5-10 characters...
3
by: Beeeeeves | last post by:
Anyone have any ideas on how fast .NET regexes are when operating on large amounts of text? (the input could be, say, 10KB of text, the regex's pattern would be fairly big ( getting on for 1KB...
1
by: Lee Kuhn | last post by:
Is there a way to add a literal character to a regex match? For example, normally applying the regex ..$ to the string "123456" results in a match "56". I want to be to add a literal character to...
1
by: Craig Kenisston | last post by:
Hi, I need to write a function that should behave like the SQL's "like" operator on a list of words. I was wondering if I can use Regex directly to do this job. But I've been reading about...
9
by: Whitless | last post by:
Okay I am ready to pull what little hair I have left out. I pass the function below my String to search, my find string (a regular expression) and my replace string (another regular expression)....
0
by: Marcel Stör | last post by:
Hi, I'm trying to parse a <table></table> combination out of a HTML string. Based to my own regex knowledge I defined the pattern as Dim strTablePattern strTablePattern = "<table...
8
by: Bob | last post by:
I need to create a Regex to extract all strings (including quotations) from a C# or C++ source file. After being unsuccessful myself, I found this sample on the internet: ...
5
by: redamazon200 | last post by:
I am looking for a way to copy a pattern (letter 'A' in the following example) to another string. string str1 = "1111AAAA111111AA"; string str2 = "1111000000001111"; After the copy str2...
2
by: John B | last post by:
I am trying to do a pretty simple pattern match using regex. The pattern is ^(?:(?<Item>.*?)@:@)*$. This should return a match for test123@:@ but does not, instead it never returns when I call...
0
by: wbosw | last post by:
I'm trying to create a regex to find more than one capital letter position within a word. The below regex, finds the first capital letter in the word and returns the index for that character. I...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.