Title |
Test
Find
Pattern Title
|
Expression |
(?=([\W]*[\w][\W]*\b))\s(?=\d\.|\d\b) |
Description |
This RegExp matches a space (" ") character with lookahead condition if there is an ASCII text in front of it and it is followed by a single decimal number which in turn is followed by a dot or nothing. It's useful to seperate scientific notation numbers from a text, i.e. when classifying with the bow toolkit.
[EDIT 18.09.2004] There was indeed an error in the second lookahead. Changed |\b to |\d\b |
Matches |
ROOT 4.873624764e-34 | `1234567 890-= 3.8765e-34543 | ~! @ # $ % ^ & ( % )_+ 3.345e-2384754 |
Non-Matches |
rstuvwxyz 754.234e-23 | yz754.234e-23 | yz .234e-23 |
Author |
Rating:
Benjamin J. J. Voigt
|
Source |
|
Your Rating |
|
Title: All right then - Changed the description
Name: Benjamin J. J. Voigt
Date: 8/5/2004 10:21:13 AM
Comment:
Of yes, of cause. Stupid me! I've changed the description of the pattern and will review it later on. Would etiquette require me to remove it?
Title: No, that's not correct...
Name: Darren Neimke
Date: 8/5/2004 8:08:22 AM
Comment:
If you look at the section of that tutorial titled: "Positive and Negative Lookbehind", you can see they clearly state:
> The construct for positive lookbehind is (?<=text):
> a pair of round brackets, with the opening bracket
> followed by a question mark, "less than" symbol and an
> equals sign. Negative lookbehind is written as
> (?<!text), using an exclamation point instead of an
> equals sign.
Notice that they have a '<' sign in there! That's the difference between lookahead and lookbehind:
lookahead: (?=...)
lookbehind: (?<=...)
Title: Doesn't seem right
Name: Darren Neimke
Date: 8/4/2004 7:08:09 PM
Comment:
This pattern doesn't seem right for several reasons...
You say - "character with lookahead/look behind condition" - but I don't see any lookbehind condition there. I can't even see why a pattern such as this would need Lookaround; surely Lookaround for something such as this would only *add* complexity?
Why wouldn't a pattern such as:
^\b\w+\b[ ]\d+\.\d+(?:e\-\d+)?
...work?
** NOTE: Obviously, in my example pattern you would need to provide a fuller implementation of Decimal matching.