Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Regex out a comma (Read 2181 times)
Martin_W
Senior Member
****
Offline


I love YaBB 1G - SP1.2!

Posts: 463
Location: Devon
Joined: Jun 22nd, 2005
Gender: Male
Regex out a comma
Apr 8th, 2009 at 6:33am
Print Post  
I have got a string as below:

$data = qq~data_a1,data_a2,data_a3|data_b1,data_b2,data_b3|data_c1,data_c2,data_c3~;

I am splitting the string by the | and then splitting the resulting 3 strings when neccessary by the comma.

Trouble is, some of the data could end up with a comma in it which I foolishly did not forsee.

I know you can regex out stuff before saving it, but how to you deal with a comma?  Is there an equivalent &nbsb(new line) for a comma?

I shall carry on googling and playing!
  
Back to top
WWW  
IP Logged
 
deti
Full Member
***
Offline


YaBB is the best!!!

Posts: 101
Location: Prien am Chiemsee
Joined: Mar 13th, 2008
Re: Regex out a comma
Reply #1 - Apr 8th, 2009 at 9:34am
Print Post  
This may help you Wink

http://www.utf8-zeichentabelle.de/unicode-utf8-table.pl?number=1024&utf8=string-...

U+002C      ,      \x2c            ,      ,      COMMA



Other thing you can do: divide it by other character:

$data = qq~data_a1#data_a2#data_a3|data_b1#data_b2#data_b3|data_c1#data_c2#data_c3~;
  

Was immer Du tun kannst
oder erträumst tun zu können,
beginne es.
Kühnheit besitzt Genie,
Macht und magische Kraft.
Beginne es jetzt.
Whatever you can do
or dream you can,
begin it.
Boldness has genius,
power and magic in it.
Begin it now.
Johann Wolfgang Goethe
Back to top
 
IP Logged
 
Martin_W
Senior Member
****
Offline


I love YaBB 1G - SP1.2!

Posts: 463
Location: Devon
Joined: Jun 22nd, 2005
Gender: Male
Re: Regex out a comma
Reply #2 - Apr 11th, 2009 at 8:42am
Print Post  
Thanks!

It was as simple as that Grin
  
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint