LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-09-2006, 05:53 AM   #1
Thinking
Member
 
Registered: Oct 2003
Posts: 249

Rep: Reputation: 30
php regex: escaped characters?


hiho@ll

i have a big problem with this:
$string = "test:test_test";

with a regex (and using e.g. preg_split) i want to split the above string into:
test
test
test

(how this stuff can be found within the array doesn't matter, the stringparts should be correctly)

the above example works with this:
$regex = "/[^A-Za-z0-9=]/";
e.g.
preg_split($regex,$string);

thats what i want and it works
explanation: split a string using a seperator which is NOT one of those characters: A-Za-z0-9=
but it's not complete:
i want this too
split a string using a seperator which is NOT one of those characters: A-Za-z0-9= AND a escaped non A-Za-z0-9 character!!!!

example: test:test\_test
result: test
test_test
if the result is test\_test it's not a problem

BUT i don't get it work

so any help would be great

thx@ll

Last edited by Thinking; 02-09-2006 at 05:56 AM.
 
Old 02-09-2006, 10:01 AM   #2
jpbarto
Senior Member
 
Registered: Mar 2003
Location: Pittsburgh, PA
Distribution: Gentoo / NetBSD
Posts: 1,251

Rep: Reputation: 45
So to make sure I understand this clearly: you want a string s to be split into tokens using delimiters which are anything but alphanumeric characters, the '=', and escaped non-alphanumeric characters. To simplify:

delimiter = unescaped non-alphanumeric characters

I don't have the ability to test it however this *might* help:

To match any escaped non-alphanumeric would be:
/\\[^A-Za-z0-9=]/

Perhaps the following:
/[^\\][^A-Za-z0-9=]/

This should match any non-alphanumeric character whose preceeding character is NOT a '\'.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
regex Perl help igotlongestname Programming 2 09-14-2005 07:51 PM
renaming file with escaped ascii, octal or anything whansard Linux - General 2 08-07-2005 08:59 AM
Regex Help cmfarley19 Programming 5 03-31-2005 10:13 PM
PHP regex replace? iluvatar Programming 5 09-10-2004 10:03 AM
ip address REGEX Robert0380 Programming 16 08-15-2003 01:00 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration