reg exp problem 
Author Message
 reg exp problem

Hello

how do I match something from "name=" to: \s or ">"  ?

e.g

"name=*(\s | >)" or something, tried a million combination, nothing
works
/Lasse



Sat, 17 May 2003 03:00:00 GMT  
 reg exp problem
"*" doesn't mean any characters, it means 0 or more of the previous
character! Your regular expression says look for "name" followed by 0 or
more "=" followed by whitespace or ">".

  re = /name=.+?(\s|>)/i;  // JS5.5 required for non-greedy match.

Or, if the name can only contain letters, digits and "_":

  re = /name=\w+/i;

=-=-=
Steve
-=-=-


Quote:
> Hello

> how do I match something from "name=" to: \s or ">"  ?

> e.g

> "name=*(\s | >)" or something, tried a million combination, nothing
> works
> /Lasse



Sat, 17 May 2003 03:00:00 GMT  
 reg exp problem

Quote:

> Hello

> how do I match something from "name=" to: \s or ">"  ?

> e.g

> "name=*(\s | >)" or something, tried a million combination, nothing
> works

How about

name=([^\s>]*)[\s|>]

:)

Quote:

> /Lasse



Sat, 17 May 2003 03:00:00 GMT  
 reg exp problem
I got it to work, I used "name=([^>\s]+)"

and I have no idea how that can work since the "+" is last :)
but since it works I'll just accept it :) or can someone please explain
this?

I can't imagine how it can match

name=*>
and
name=*[space]

/Lasse

Quote:

> Hello

> how do I match something from "name=" to: \s or ">"  ?

> e.g

> "name=*(\s | >)" or something, tried a million combination, nothing
> works
> /Lasse



Sun, 18 May 2003 03:00:00 GMT  
 reg exp problem
Your regexp matches:
- the literal string "name=", followed by
- one or more (that's what the "+" means) characters, except (the "^"
immediatly
  following the "[") a ">" or a space

So it is a correct match for
... name=myName>...
...name="myName" value...

But not for
.. name="spaced name" ...
(but that probably will not happen)

Hans Kesting


Quote:
> I got it to work, I used "name=([^>\s]+)"

> and I have no idea how that can work since the "+" is last :)
> but since it works I'll just accept it :) or can someone please explain
> this?

> I can't imagine how it can match

> name=*>
> and
> name=*[space]

> /Lasse


> > Hello

> > how do I match something from "name=" to: \s or ">"  ?

> > e.g

> > "name=*(\s | >)" or something, tried a million combination, nothing
> > works
> > /Lasse



Sun, 18 May 2003 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. urgent Reg Exp problem

2. urgent REG EXP problem!

3. Urgent Reg Exp problem

4. reg exp without reg exp

5. url validation reg exp

6. reg exp and extended chars

7. vbs IsDate() implemented as reg exp

8. First Foray into reg exp and javascript

9. Reg.Exp - steve!-

10. Reg.Exp *repost* - Steve -

11. Reg Exp - STEVE PLZ! :)

12. Reg Exp - infinite loop

 

 
Powered by phpBB® Forum Software