Message Boards Message Boards

0
|
2007 Views
|
2 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Conditional strings joining?

Posted 11 years ago
I have a following question : I've got the list :
{"{0, 90012}", "{0, 90013}", "{0, 90016}", "{0, 90022}", "{0, 90034}",
"{0, 90042}", "{0, 70102}", "{0, 90106}", "{0, 90115}", "{0, 90131}",
"{0, 90132}", "{0, 90137}", "{0, 90153}", "{0, 90214}", "{0, 90222}",
"{0, 90226}", "{0, 50230}", "{0, 20234}", "{0, 90239}", "{0, 90247}",
"{0, 90304}", "{0, 90306}", "{0, 90312}", "{0, 90316}", "{0, 90323}",
"{0, 90325}", "{0, 90328}", "{0, 90331}", "{0, 90332}", "{0, 90333}",
"{0, 90336}", "{0, 90344}", "{0, 90349}", "{0, 90351}", "{0, 90354}",
"{0, 90358}", "{0, 90408}", "{0, 90413}", "{0, 90416}", "{0, 90417}"}
I'd like to join only these strings which have 9 right after comma ----f.e.---"{090012}","{090013}"....... and to take strings of numbers which start after
comma for the others ------f.e.----"{70102}","{20234}" CanĀ  conditional flow functions be applied for this ?
POSTED BY: Artur Kotarski
2 Replies
Posted 11 years ago
Thank You for reply
POSTED BY: Artur Kotarski
One possible way is
 StringReplace[list, {"0, 9" -> "09", "0, " -> ""}]
 
 (* Out[3]= {"{090012}", "{090013}", "{090016}", "{090022}", "{090034}", "{090042}",
  "{70102}", "{090106}", "{090115}", "{090131}", "{090132}", "{090137}",
  "{090153}", "{090214}", "{090222}", "{090226}", "{50230}", "{20234}",
  "{090239}", "{090247}", "{090304}", "{090306}", "{090312}", "{090316}",
  "{090323}", "{090325}", "{090328}", "{090331}", "{090332}", "{090333}",
  "{090336}", "{090344}", "{090349}", "{090351}", "{090354}", "{090358}",
  "{090408}", "{090413}", "{090416}", "{090417}"} *)

The following tutorial may be of interest:

Working with String Patterns
POSTED BY: Ilian Gachevski
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract