regex - Question On Text Parsing In Perl -


i want parse line this,

s1,f2  title including several white spaces  (abbr) single,here<->there,reply 

and want output below,

1 2 title including several white spaces abbr single here22there  # identify <-> , translate 22;  reply 

i wondering how parse line above?

method 1. plan split whole line 4 segments parse individual sub segments.

segment1. s1,f2

segment2. title including several white spaces

segment3. abbr

segment4. single,here<->there,reply

method 2. write complex regular expression statement parse it.

which method more make sense practice?

appreciated on comments or suggestions.

assuming input in format specified use regex like:

^s(\d+),f(\d+)\s+(.*?)\((.*?)\)\s+(.*?),(.*?),(.*)$ 

codepad link


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -