you can always use http://www.rubular.com/ to test your RexExp.

On Oct 6, 10:25 pm, "Johannes J. Schmidt" <[EMAIL PROTECTED]> wrote:
> eg /(\d+\.){0,1}\d+$/
>
> g jo
>
> Am Mittwoch, den 24.09.2008, 16:20 -0700 schrieb ressister:
>
> > Hi there, I'm trying to split a string using RegExp to extract a price
> > from it.  The price may or may not have a dollar sign in front of it
> > and may or may not contain a decimal value.  Below are some string
> > examples of what the regular expression would need to handle to split
> > out the price:
>
> > Example 1:
> > "2 starbuck's coffees 9.99"    <- price is 9.99
>
> > Example 2:
> > "99 red baloons 175"   <- price is 175
>
> > Example 3:
> > "starbuck's coffee $9.99"  <- price is 9.99
>
> > Example 4:
> > "starbucks coffee 9"   <- price is 9
>
> > So the trouble is: a) in Example 3, I can't count on the dollar sign
> > being there all the time.  Some instances it will, other instances it
> > won't and b) in the case of Example 2, there may be a number at the
> > start of the string of indeterminate length that I want to ignore
> > since this could represent the quantity, not the price.
>
> > What would the RegExp look like that would split out the price?
>
> > Thanks in advance.
> > -A
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to