Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: utf weirdness in regex

by hbo (Monk)
on Jul 23, 2004 at 06:06 UTC ( #376811=note: print w/replies, xml ) Need Help??

in reply to utf weirdness in regex

/^[\w\s.]+$/ is equivilant to /^.+$/, right? I suspect the trailing period in the class is not what you intended.

No Idea about the unicode fun with $string1, though.

"Even if you are on the right track, you'll get run over if you just sit there." - Will Rogers

Replies are listed 'Best First'.
Re^2: utf weirdness in regex
by december (Pilgrim) on Jul 24, 2004 at 04:28 UTC

    No, it's only any_letter and spaces (I hope). It's supposed to check that a filename only consists of letters (as opposed to control characters, which I'm filtering for).

    The trailing period is supposed to be there for the dot in the filename.

    Unicode makes things *hard*. :)

      But the period matches any character if it isn't escaped.
      /[\w\s\.]+/ # one or more word, space or period characters /[\w\s.]+/ # one or more word. space or *any* characters /.+/ # same as above
      "Even if you are on the right track, you'll get run over if you just sit there." - Will Rogers

        Note that inside a character class, a period is not special: it means just period. So this:

        would match one or more of (word chars, space chars, periods) in any combination.

        In other words, your first two examples are equivalent, not your second two.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://376811]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (8)
As of 2018-01-17 16:00 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (201 votes). Check out past polls.