Jump to content

Regular Expressions

- - - - -

  • Please log in to reply
2 replies to this topic

#1
Stasonix

Stasonix

    Learning Programmer

  • Members
  • PipPipPip
  • 82 posts
  • Programming Language:C++, PHP, JavaScript, Delphi/Object Pascal, Pascal
  • Learning:C++, PHP, JavaScript, Delphi/Object Pascal
I have a text: colname: green, rgb(255, 0 ,255); colname: white, rgb(0, 0, 0); colname: green, rgb(255, 0 ,255); colname: white, rgb(0, 0, 0);
how to parse names of the colors in $name, and rgb into $rgb variables?
must be:
$name[0]="green";
$rgb[0]="rgb(255, 0 ,255)";
$name[1]="white";
$rgb[1]="rgb(0, 0 ,0)";
...

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
The regex would look something like:
: ([a-z]*), ([^;]*);

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
Stasonix

Stasonix

    Learning Programmer

  • Members
  • PipPipPip
  • 82 posts
  • Programming Language:C++, PHP, JavaScript, Delphi/Object Pascal, Pascal
  • Learning:C++, PHP, JavaScript, Delphi/Object Pascal
Yes, thank you WingedPanther




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users