# Some help needed on regex

**URL:** <https://www.ruby-forum.com/t/some-help-needed-on-regex/125081>\
**Category:** Ruby\
**Created:** [January 5, 2008, 3:46am UTC](https://www.ruby-forum.com/t/some-help-needed-on-regex/125081 "2008-01-05T03:46:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Junkone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e274bd/32.png) [@Junkone](https://www.ruby-forum.com/u/Junkone)\
**Post date:** [January 5, 2008, 3:46am UTC](https://www.ruby-forum.com/t/some-help-needed-on-regex/125081/1 "2008-01-05T03:46:21Z")

</div>

I have a very complex regex requirement and need some hand here. I can  
do only very basic regex.  
I need to do the following

add \<symbol f|s i|p|e h|l number \>

1. has to be either of the following strings add , modify
2. followed by any word composed of string or number
3. followed by one of the 2 letters f,s
4. followed by either one or more of the letters i,p,e
5. followed by of letters followed by number. the letters can be  
either h or l and the number can be decimal or round number.  
for eg. h and/or l 

appreciate any help here.

---

<div class="post-metadata">

**Author:** ![Junkone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e274bd/32.png) [@Junkone](https://www.ruby-forum.com/u/Junkone)\
**Post date:** [January 5, 2008, 3:53am UTC](https://www.ruby-forum.com/t/some-help-needed-on-regex/125081/2 "2008-01-05T03:53:23Z")

</div>

well since you can describe it in english alright…

TextualRegexp

---

<div class="post-metadata">

**Author:** ![Junkone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e274bd/32.png) [@Junkone](https://www.ruby-forum.com/u/Junkone)\
**Post date:** [January 5, 2008, 3:58am UTC](https://www.ruby-forum.com/t/some-help-needed-on-regex/125081/3 "2008-01-05T03:58:03Z")

</div>

break it down… these aren’t all _exactly_ to your specs–it’s less  
specific, just a start  
(I would consider not even using a regular expression here…)

1. (add|modify)
2. \S+ (any non-whitespace, not exact)
3. [fs]
4. [ipe]
5. [hl] [.0-9]+

Combined, something like:  
(add|modify)\s+\S+\s+[fs]\s+[ipe]\s+[hl]\s+[.0-9]+

Of course, this ignores \< and \>.

But, oww, my head…  
“Some people, when confronted with a problem, think “I know, I’ll use  
regular expressions.” Now they have two problems.” – Jamie Zawinski
