\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
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
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
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
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,
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
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
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
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
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.
$ 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
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
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
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
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,
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:
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
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
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
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
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
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
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
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 =
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
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.
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
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
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,
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
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
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
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
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,
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
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
\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
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,
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
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
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
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.
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
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
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
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]
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
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]
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
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
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
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
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
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,
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
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
56 matches
Mail list logo