[Rails] Re: regular expression

2010-06-05 Thread Srinivas Golyalla
\d{3}_\d{3}_\d{4}., thats the answer., i really appreciate., thanks a lot. Can you guide me for this please., 2. In Ruby there is a command called ‘require’. Explain what this command means and write an example of how it is used to include a Ruby Gem in a file. On Jun 4, 4:49 pm, Rob

[Rails] Re: regular expression

2010-06-04 Thread Frederick Cheung
On Jun 4, 1:28 pm, Srinivas Golyalla golya...@gmail.com wrote: Can u help me in simple regular expression that will match the string ‘123_456_7890’ but not ‘123_456_789’. You're going to have to be a little more specific - the regular expression /0/ matches the first string and not the second

[Rails] Re: regular expression

2010-06-04 Thread Srinivas Golyalla
ENTER http://rubular.com/ I Need regular expression that will match the string '123_456_7890' not '123_456_789' On Jun 4, 9:38 am, Peter De Berdt peter.de.be...@pandora.be wrote: On 04 Jun 2010, at 14:28, Srinivas Golyalla wrote: Can u help me in simple regular expression that will match

[Rails] Re: regular expression

2010-06-04 Thread chewmanfoo
Do you know a site of that quality (rubular.com) for XPath??? That site rocks!!! On Jun 4, 1:16 pm, Srinivas Golyalla golya...@gmail.com wrote: ENTERhttp://rubular.com/ I Need regular expression that will match the string '123_456_7890'  not '123_456_789' On Jun 4, 9:38 am, Peter De Berdt

Re: [Rails] Re: regular expression

2010-06-04 Thread Rob Biedenharn
Well, Google found this one pretty quick: http://www.mizar.dk/XPath/Default.aspx Maybe it can find others, too, if that one doesn't work for you. -Rob On Jun 4, 2010, at 4:40 PM, chewmanfoo wrote: Do you know a site of that quality (rubular.com) for XPath??? That site rocks!!! On Jun 4,

[Rails] Re: regular expression problem

2010-04-27 Thread Ben Woodcroft
HUNT HUNT wrote: var text=Afganistan (+86) var code=text.sub(/\w+/, '') result: code = (+86) -- var text = Antigua and Barbuda (+1268) var code=text.sub(/\w+/, '') result : code = and Barbuda (+1268) -- what regular

[Rails] Re: regular expression problem

2010-04-27 Thread HUNT HUNT
Vladimir Rybas wrote: nice one David! I did with this var code=text.sub(/[a-z A-Z]/, '') -- Posted via http://www.ruby-forum.com/. -- 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

[Rails] Re: regular expression problem

2010-04-27 Thread Marnen Laibow-Koser
David A. Black wrote: Hi -- On Tue, 27 Apr 2010, Vladimir Rybas wrote: Antigua and Barbuda (+1268).scan(/\d+/).to_s = 1268 Antigua and Barbuda (+1268).scan(/\(\+\d+\)/).to_s = (+1268) There's a nice technique for quickly getting a substring from a string using a subscript-style

[Rails] Re: regular expression

2010-03-31 Thread tonypm
Interesting to see two regexperts slogging it out :) Seriously though, I have to confess I have a real block when it comes to regexp. There seem to be so many variants of ways of doing things. This example is the sort of thing I have done in the past, but never so elegantly. Trouble is I am

[Rails] Re: regular expression

2010-03-31 Thread DmitryPush
This is very good tutorial (don't be upset its for perl, in ruby regexp works pretty the same) http://sunsite.ualberta.ca/Documentation/Misc/perl-5.6.1/pod/perlretut.html a. - [] - causing group of symbols, for eg /[bcr]at/ matches 'bat, 'cat', or 'rat' b. 1 - it's a first math ($1 in perl) c.

[Rails] Re: regular expression

2010-03-24 Thread DmitryPush
$ irb module$block.item[/\$([^.]*)\./,1] = block -- 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-t...@googlegroups.com. To unsubscribe from this group, send email to

Re: [Rails] Re: regular expression

2010-03-24 Thread Andy Jeffries
Dmitry posted pretty much the same solution as I did, but a slightly different regular expression. On Ruby 1.8.7 (your Ruby version may vary) my regex is *slightly* faster. On Ruby 1.9.1 his is *slightly* faster. The difference is 0.3s over 10,000,000 iterations, so either way it's pretty

[Rails] Re: regular expression

2010-03-24 Thread DmitryPush
A came to ruby from perl and as I know my solution faster there. Ofcourse in this case it doesn't matter. But understating how works your and mine solutions may be useful... I've seen your massage and post mine only for educational reasons. Plus mine look's nicer, I just kidding:) PS I don't know

Re: [Rails] Re: regular expression

2010-03-24 Thread Andy Jeffries
On 24 March 2010 09:22, DmitryPush dmitryp...@gmail.com wrote: A came to ruby from perl and as I know my solution faster there. Ofcourse in this case it doesn't matter. But understating how works your and mine solutions may be useful... Absolutely I've seen your massage and post mine only

[Rails] Re: Regular expression: How do I allow forward slashes?

2009-12-20 Thread frogstarr78
Yeah, I understand what you mean. No worries. On Dec 19, 11:10 pm, AlwaysCharging goodg...@gmail.com wrote: But that made me question why I couldn't just put the / inside of the bracket as well.  Like why did that have to be escaped if the period didn't.  (I guess it's because in that syntax,

[Rails] Re: Regular expression: How do I allow forward slashes?

2009-12-19 Thread frogstarr78
Have you tried escaping them \/? On Dec 18, 11:01 pm, AlwaysCharging goodg...@gmail.com wrote: In my app, I allow users to submit urls.  They (of course) need the ability to submit urls with a forward slash, /, but whats the regular expression to allow them to do that? I currently use:

Re: [Rails] Re: Regular expression: How do I allow forward slashes?

2009-12-19 Thread Sven Riedel
frogstarr78 wrote: Have you tried escaping them \/? Another way would be to use %r, that way you can avoid the leaning toothpick syndrome alltogether; /^http:\/\/myhostname\.com\/foo$/i would become %r{http://myhostname\.com/foo}i But before you start piecing your own regexp together have a

Re: [Rails] Re: Regular expression: How do I allow forward slashes?

2009-12-19 Thread Sven Riedel
Sven Riedel wrote: /^http:\/\/myhostname\.com\/foo$/i would become %r{http://myhostname\.com/foo}i And of course I forgot the anchors in the second example. So the correct version is: %r{^http://myhostname\.com/foo$}i -- You received this message because you are subscribed to the Google

[Rails] Re: Regular expression: How do I allow forward slashes?

2009-12-19 Thread Alan
Use Ruby's other regexp syntax: %r{pattern} To continue your example below: validates_format_of :url, :with = %r{^[-\w_./]+$} AlwaysCharging wrote: In my app, I allow users to submit urls. They (of course) need the ability to submit urls with a forward slash, /, but whats the regular

[Rails] Re: Regular expression: How do I allow forward slashes?

2009-12-19 Thread AlwaysCharging
Yes, that did it. Thank you. No idea how I try everything and overlook the simplest solution, duh. And, Thank you to everyone else that weighed in as well, definitely some other options to look into. Side note: Anybody know why the period doesn't have to be escaped? Like just . allows the dot

[Rails] Re: Regular expression: How do I allow forward slashes?

2009-12-19 Thread frogstarr78
It actually depends on where the . is in the Regexp. In your case it is inside a Character Class []. So it is matching the . character explicitly. Since \w is shorthand for the [a-zA-Z] character class. It is parsed as a character class instead of an escaped w character. So you could actually

Re: [Rails] Re: Regular expression: How do I allow forward slashes?

2009-12-19 Thread maryam kamali
hello iam maryam ihave peroblem ishal go aftenon by On Sat, Dec 19, 2009 at 11:21 AM, ralu ralu...@gmail.com wrote: On Dec 18, 11:01 pm, AlwaysCharging goodg...@gmail.com wrote: In my app, I allow users to submit urls. They (of course) need the ability to submit urls with a forward

[Rails] Re: Regular expression: How do I allow forward slashes?

2009-12-19 Thread AlwaysCharging
But that made me question why I couldn't just put the / inside of the bracket as well. Like why did that have to be escaped if the period didn't. (I guess it's because in that syntax, the forward slash has closure properties.) Oh well it's working now, and I escaped the . as well (\.). Thank you

[Rails] Re: Regular expression: How do I allow forward slashes?

2009-12-18 Thread ralu
On Dec 18, 11:01 pm, AlwaysCharging goodg...@gmail.com wrote: In my app, I allow users to submit urls.  They (of course) need the ability to submit urls with a forward slash, /, but whats the regular expression to allow them to do that? I currently use: validates_format_of :url, :with =

[Rails] Re: regular expression help needed

2009-09-14 Thread Sandip Ransing
Thanks buddies ! I am sure that in next couple of hours, will able to write complex regex ! -- Sandip --~--~-~--~~~---~--~~ 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

[Rails] Re: regular expression help needed

2009-09-11 Thread Dhruva Sagar
Well for the example string you have given, this does the job : reg = /(.*):\s+(.*)/ s = HYDERABAD/NEW DELHI: Andhra Pradesh chief minister was reg.match(s) location = $1 # = HYDERABAD/NEW DELHI plain_content = $2 # = Andhra Pradesh chief minister was Thanks Regards, Dhruva Sagar.

[Rails] Re: regular expression help needed

2009-09-11 Thread Sandip Ransing
Thanks ! What will be the regular expression to extract *IANS* and *3 September 2009, 02:57pm IST* from following string * IANS 3 September 2009, 02:57pm IST * Sandip -- Ruby on Rails Developer http://sandip.sosblog.com http://funonrails.wordpress.com www.joshsoftware.com

[Rails] Re: regular expression help needed

2009-09-11 Thread Dhruva Sagar
reg = /(.*)\s([0-9]\s.*)/ s = IANS 3 September 2009, 02:57pm IST reg.match(s) location = $1.strip # = IANS plain_content = $2.strip # = 3 September 2009, 02:57pm IST Thanks Regards, Dhruva Sagar. Ogden Nash http://www.brainyquote.com/quotes/authors/o/ogden_nash.html - The trouble with a

[Rails] Re: regular expression matching date, author and agency in string

2009-09-11 Thread Abhinav Saxena
Not to sound rude, but you should do it yourself. It will help you in your programming career. Moreover, it's not a rails related issue. You can use Internet search for learning more about regex. This is first result I got on Google: http://www.regular-expressions.info/reference.html Thanks,

[Rails] Re: regular expression help needed

2009-09-11 Thread prashanth hiremath
Hi If i have an file name bangalore.txt if i wanna remove .txt and assign bangalore to temp variable how can it achieve. Regards prashanth On Fri, Sep 11, 2009 at 5:13 PM, Dhruva Sagar dhruva.sa...@gmail.comwrote: reg = /(.*)\s([0-9]\s.*)/ s = IANS 3 September 2009, 02:57pm

[Rails] Re: regular expression matching date, author and agency in string

2009-09-11 Thread David A. Black
Hi -- On Fri, 11 Sep 2009, Sandip Ransing wrote: Hello All, I wanted regular expression for the following patterns like Nauzer Bharucha, TNN 10 September 2009, 12:01am IST IANS 3 September 2009, 02:57pm IST regular expression should return date in first group author in second

[Rails] Re: regular expression help needed

2009-09-11 Thread Abhinav Saxena
1. Go to Google.com 2. Type keywords: Ruby File basename 3. Press I am feeling lucky Thanks, Abhinav -- अभिनव http://twitter.com/abhinav On Fri, Sep 11, 2009 at 5:37 PM, prashanth hiremath prashanthhirema...@gmail.com wrote: Hi If i have an file name bangalore.txt if i

[Rails] Re: regular expression help needed

2009-09-11 Thread Dhruva Sagar
If you need RegExp help this would help you : s = 'Bangalore.txt' regexp = /(.*)\.(/*)/ regexp.match(s) baseName = $1 # = Bangalore But I must say, you should try google a bit more often as Abhinav mentioned. Thanks Regards, Dhruva Sagar. Ted Turner

[Rails] Re: Regular expression

2009-06-20 Thread Newb Newb
Simon Macneall wrote: Perhaps it's best if you try, and then if you fail ask the question? Otherwise you will be asking on the list everytime you need a regular expression I recomment the following http://www.addedbytes.com/cheat-sheets/regular-expressions-cheat-sheet/ Simon On Sat,

[Rails] Re: Regular expression

2009-06-20 Thread Newb Newb
Is it possible to limit the input upto two digits using regex -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email

[Rails] Re: Regular expression

2009-06-20 Thread Felix Schäfer
1. Please refrain from bumping your topic so often, you clearly stated your request in a previous post, there is no need to repost with no added information 10 minutes later. The only thing you might achieve is to deter people that may help you. 2. Most people here don't mind helping people

[Rails] Re: Regular expression

2009-06-19 Thread s.ross
\d+ On Jun 19, 2009, at 10:44 PM, Newb Newb wrote: hi friends.. in my application i have number of days field. it Should not allow user to input special characters in the field.and it Should not allow blank space in the Number of Days field. what regular expression can i use... Thanks

[Rails] Re: Regular expression

2009-06-19 Thread Simon Macneall
Perhaps it's best if you try, and then if you fail ask the question? Otherwise you will be asking on the list everytime you need a regular expression I recomment the following http://www.addedbytes.com/cheat-sheets/regular-expressions-cheat-sheet/ Simon On Sat, 20 Jun 2009 13:44:15 +0800,

[Rails] Re: Regular Expression question

2009-03-01 Thread pepe
Hi. I just tested the regexp against 19. and it works, but I got a little problem with the [\s\n]I just solved: s = '19. / 482.600 mm / 19.06 / 482.600 mm' s.gsub!(/(\.0?[^0])?0+/, '\1').gsub!(/\.([\s\n])/, '\1') This produces: '19 / 482.6 mm / 19.06 / 482.6 mm' The insignificant

[Rails] Re: Regular Expression question

2009-02-28 Thread pepe
string = '10.0' string.sub!(/\.\d+/, '') This will replace in place (sub!) any dot (\.) followed by at least one number (\d+) with nothing (''). Pepe On Feb 27, 4:37 pm, northband_101 northb...@gmail.com wrote: Awesome - this is a start - I'll take it from here. Thanks! On Feb 27, 4:14 

[Rails] Re: Regular Expression question

2009-02-28 Thread pepe
Sorry, I didn't read your first posting fully. My solution will not work for the case of 482.600. Pepe On Feb 28, 10:12 am, pepe p...@betterrpg.com wrote: string = '10.0' string.sub!(/\.\d+/, '') This will replace in place (sub!) any dot (\.) followed by at least one number (\d+) with

[Rails] Re: Regular Expression question

2009-02-28 Thread pepe
OK, got something working you might be able to use. Just to make things more complicated: s = '19.0 / 482.600 mm / 19.060 / 482.600 mm' s.gsub!(/(\.0?[^0])?0+/, '\1').gsub!(/\.[\s\n]/, '') Pepe On Feb 28, 10:13 am, pepe p...@betterrpg.com wrote: Sorry, I didn't read your first posting fully.

[Rails] Re: Regular Expression question

2009-02-28 Thread Matt Jones
There appear to be some good solutions here, but I thought I'd jump in with a bit of non-Rails technical detail. I'd double check with the source of this data - the zeros may be significant. (see http://en.wikipedia.org/wiki/Significant_figures) The data given doesn't seem to match that

[Rails] Re: Regular Expression question

2009-02-27 Thread Rob Biedenharn
On Feb 27, 2009, at 2:47 PM, northband wrote: Hi - I would like to use gsub() to strip decimals with trailing zeros from a string. My string looks like this: -- 19.0 / 482.600 mm -- I would like to end up with this: -- 19 / 482.6 mm -- Anyone have a regular expression that can

[Rails] Re: Regular Expression question

2009-02-27 Thread northband_101
Awesome - this is a start - I'll take it from here. Thanks! On Feb 27, 4:14 pm, Rob Biedenharn r...@agileconsultingllc.com wrote: On Feb 27, 2009, at 2:47 PM, northband wrote: Hi - I would like to use gsub() to strip decimals with trailing zeros from a string.  My string looks like

[Rails] Re: Regular Expression Grouping

2008-10-19 Thread Frederick Cheung
On 19 Oct 2008, at 15:01, mars wrote: Hi! I couldn't understand the behavior of this code: match = 'Today is Feb 23rd, 2003'.match(/Feb 23(rd)?/) a = match.to_a puts a.size# 2 puts a.join(,) # Feb 23rd,rd puts a[0] # Feb 23rd puts a[1]

[Rails] Re: Regular Expression Grouping

2008-10-19 Thread Marcelino Debajo
Yeah you're right, match = 'Today is Feb 23rd, 2003'.match(/Feb 23(rd)??/) match[0] #= Feb 23 match[1] #= nil I expected: match = 'Today is Feb 23rd, 2003'.match(/Feb 23(rd)?/) # ? is greedy here match[0] #= Feb 23rd match[1] #= nil But what I got in ruby 1.8.6 (2007-09-24

[Rails] Re: Regular Expression Grouping

2008-10-19 Thread Frederick Cheung
On 19 Oct 2008, at 16:04, Marcelino Debajo wrote: Yeah you're right, match = 'Today is Feb 23rd, 2003'.match(/Feb 23(rd)??/) match[0] #= Feb 23 match[1] #= nil I expected: match = 'Today is Feb 23rd, 2003'.match(/Feb 23(rd)?/) # ? is greedy here match[0] #= Feb 23rd match[1]

[Rails] Re: Regular Expression Grouping

2008-10-19 Thread Marcelino Debajo
thanks Fred. I think I misunderstood something. On Mon, Oct 20, 2008 at 12:14 AM, Frederick Cheung [EMAIL PROTECTED] wrote: On 19 Oct 2008, at 16:04, Marcelino Debajo wrote: Yeah you're right, match = 'Today is Feb 23rd, 2003'.match(/Feb 23(rd)??/) match[0] #= Feb 23 match[1] #= nil

[Rails] Re: Regular Expression pattern matching question...

2008-10-07 Thread Johannes J. Schmidt
Am Montag, den 06.10.2008, 15:14 -0700 schrieb Dejan Dimic: you can always use http://www.rubular.com/ to test your RexExp. This Website does not work correctly. g jo On Oct 6, 10:25 pm, Johannes J. Schmidt [EMAIL PROTECTED] wrote: eg /(\d+\.){0,1}\d+$/ g jo Am Mittwoch, den

[Rails] Re: Regular Expression pattern matching question...

2008-10-06 Thread Dejan Dimic
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

[Rails] Re: Regular expression to identity special character

2008-09-28 Thread MarcRic
Hi Abhishek, Take a look on this article: http://marcricblog.blogspot.com/2008/08/bitwising-ruby.html More specifically, the last example. On that case I just consider words. You will need to adapt it to your needs. Regards. On Sep 27, 11:05 am, Abhishek shukla [EMAIL PROTECTED] wrote: yes

[Rails] Re: Regular expression to identity special character

2008-09-27 Thread Frederick Cheung
On Sep 27, 12:36 pm, Abhishek shukla [EMAIL PROTECTED] wrote: Hello friends i need a regular expression which will check if the string contain the special character or not? and accordingly it should return true, false value. Depends entirely on what you mean by special character? Fred

[Rails] Re: Regular expression to identity special character

2008-09-27 Thread Frederick Cheung
That's still not very precise. Do you mean anything that's not a letter or a space? What about punctuation, numbers etc... ? You're probably just going to end up with one of the builtin character classes like \w or custom ones like [a-z] Sent from my iPhone On 27 Sep 2008, at 12:47,

[Rails] Re: Regular expression to identity special character

2008-09-27 Thread Abhishek shukla
yes basically i don't want my string should contain any 'punctuation' if so then it should return false. regards abhishek On Sat, Sep 27, 2008 at 6:11 PM, Frederick Cheung [EMAIL PROTECTED] wrote: That's still not very precise. Do you mean anything that's not a letter or a space? What about

[Rails] Re: Regular Expression help

2008-09-10 Thread Brendon
Here's what we came up with using StringScanner: def processed_answer scanner = StringScanner.new(correct_answers) # last position the scanner was in last_pos = 0 output = [] while scanner.scan_until(/\[(.+?)\]/) # non-greedy matching so we only swallow the first bracket