regular expression urgent

Alles, was PHP betrifft, kann hier besprochen werden.

regular expression urgent

Postby pathfinder80 » 11. July 2007 19:08

I am using preg_match to match a expression.
"hello_123" or " hello_123 " (valid expression. the text inside double quotes also can be a utf8 character)
" "hello_123" " or ""hello_123"" (not valid)
" hello_123 " (not valid there should be no tabs within the double quotes)

the pattern that I wrote is given below.
(\"([^\t]\s?[^\"]([a-zA-Z0-9])[^\t]\s?|[^\t]\s?(\X)\s?|([\s])+)\") but this seems not to work. Cpuld someone please help me out.

Thanks in advance.
pathfinder80
 
Posts: 12
Joined: 26. June 2007 22:13

Postby Memory » 12. July 2007 09:59

/^"hello123 ?"$/
Memory
 
Posts: 42
Joined: 10. May 2007 15:36

Postby Memory » 12. July 2007 10:05

its better
Code: Select all
/^"([a-zA-Z0-9])*[\t]?"$/


valid
Code: Select all
"asdfg"
"qwertz<\t>"

"<\t>" means tabulator

invalid
Code: Select all
"qwertz<space>"
"<\t>qwertz"
"qwertz<\t><\t>"
""qwertz<\t>""
"<space>qwertz"
Memory
 
Posts: 42
Joined: 10. May 2007 15:36


Return to PHP

Who is online

Users browsing this forum: No registered users and 3 guests