Hi,
Iam facing problem in excluding new line in reular expression…(/n)
eg: shiva.grp\nhi da so it should exclude \n .if any one knows help me
Hi,
Iam facing problem in excluding new line in reular expression…(/n)
eg: shiva.grp\nhi da so it should exclude \n .if any one knows help me
You’ll have to make the regexp multline with the /m option (i.e. /foo/
m) or it won’t match across newlines.
Rein
On Sep 3, 12:36 pm, Jamal S. [email protected]
Rein H. wrote:
You’ll have to make the regexp multline with the /m option (i.e. /foo/
m) or it won’t match across newlines.Rein
On Sep 3, 12:36 pm, Jamal S. [email protected]
Thanks for your reply
this is my regular expression
my source is this
mygroup.grp
hi how r u
iam fine
str=~/^([a-zA-Z]{1}[a-zA-Z0-9]{0,}.([a-zA-Z]{1,}))\s(.*)$/m
if i put this regular expression it is not matching
I need to understand, you don’t want anything after new line?
or you want to remove \n and use your regular expression?
Shiva K. wrote:
Hi,
Iam facing problem in excluding new line in reular expression…(/n)
eg: shiva.grp\nhi da so it should exclude \n .if any one knows help me
Exclude you don’t want it?
[^\n]
something like that or ?
Jamal S. wrote:
I need to understand, you don’t want anything after new line?
or you want to remove \n and use your regular expression?
its like this
eg: shiva.grp hi how r u
eg: shiva.grp
hi how r u
both this format should accept
Hi Shivan,
I tried with this regex, it worked for both the example you mentioned.
reg = /^[a-zA-Z]+.[a-zA-Z]+[a-zA-Z ]+[\s]*$/
str = two example values you specified.
str =~ reg -----> 0(output)
On Sep 4, 1:18 pm, Shiva K. [email protected]
Matthew R. wrote:
raghukumar wrote:
Hi Shivan,
I tried with this regex, it worked for both the example you mentioned.reg = /^[a-zA-Z]+.[a-zA-Z]+[a-zA-Z ]+[\s]*$/
str = two example values you specified.
str =~ reg -----> 0(output)
On Sep 4, 1:18 pm, Shiva K. [email protected]
irb(main):001:0> regexp = /^([a-zA-Z]\w*.([a-zA-Z]+))\s(.)$/m
=> /^([a-zA-Z]\w.([a-zA-Z]+))\s(.*)$/m
irb(main):002:0> “mygroup.grp\nhi how r u\niam fine” =~ regexp
=> 0
irb(main):003:0> $1
=> “mygroup.grp”
irb(main):004:0> $2
=> “grp”
irb(main):005:0> $3
=> “hi how r u\niam fine”
thnaks man for your help
(str=~/^([a-zA-Z]{1}[a-zA-Z0-9]{0,}.([a-zA-Z]{1,}))$/i)
in the above expression it should not allow new line but it allowing
inside
pls help me…iam poor in regular expression
raghukumar wrote:
Hi Shivan,
I tried with this regex, it worked for both the example you mentioned.reg = /^[a-zA-Z]+.[a-zA-Z]+[a-zA-Z ]+[\s]*$/
str = two example values you specified.
str =~ reg -----> 0(output)
On Sep 4, 1:18 pm, Shiva K. [email protected]
irb(main):001:0> regexp = /^([a-zA-Z]\w*.([a-zA-Z]+))\s(.)$/m
=> /^([a-zA-Z]\w.([a-zA-Z]+))\s(.*)$/m
irb(main):002:0> “mygroup.grp\nhi how r u\niam fine” =~ regexp
=> 0
irb(main):003:0> $1
=> “mygroup.grp”
irb(main):004:0> $2
=> “grp”
irb(main):005:0> $3
=> “hi how r u\niam fine”
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs