Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^2: check if string is valid with special cases

by ovedpo15 (Pilgrim)
on May 15, 2018 at 10:30 UTC ( [id://1214537]=note: print w/replies, xml ) Need Help??


in reply to Re: check if string is valid with special cases (updated)
in thread check if string is valid with special cases

Im sorry, I meant that the substring can conatin commas in it. nevertheless, is it possible to include a case of space (bad case - "1,2,3, ,4,5") for the regex you wrote? I think its the regex I need.

Replies are listed 'Best First'.
Re^3: check if string is valid with special cases
by haukex (Archbishop) on May 15, 2018 at 10:58 UTC
    the substring can conatin commas in it

    Sorry, this doesn't make sense to me. If the input string is "1,2,3,4,5,6,7", then does $a get "1,2", or does $b get "2,3", and so on...

    Or is this CSV, as swl correctly pointed out? Then you should use Text::CSV.

    If not, then as I said, please provide lots of examples of valid input with the expected output, as well as lots of examples of invalid input.

      "a ,b,c,d,e" is okay (space with substring) but one space or more (without any symbols) isn't valid. For example: "a, ,c,d,e" or "a,b,c, d,e" are not valid.
      Ok I understand, forget about commas in the substrings.
      your regex is good and its what I need except it doesn't handle an empty space case: "a,b,c, d,e" (bad case).
      how can I add it to the regex?

        Again, more examples please. Only literal spaces? I am guessing you mean one or more spaces? What about other whitespace? Is " x ,..." valid? Is " x y ,..."? What is the expected output for those cases? And so on.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1214537]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2024-03-28 18:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found