Dear Everybody, I was trying to parse various strings. One rule tells that the String must contain a smaller string like HGSDC:MSISDN=919810001671,SUD=OICK7-0; which can be described by a Java regular expression "HGS?[CEI]*".
val lSTr = List("[ Hello,Hi How Do U D oo ?]", "60 HGSSE:MSISDN=919810637917,SS=BAIC,BSG=TS10;", "53 HGSDC:MSISDN=919810001671,SUD=OICK7-0;", " XGSDW")
val pat = Pattern.compile("HGS?[CEI]*") for (str <- lSTr) { if(pat.matcher(str).find()) { val tokens = new lexical.Scanner(str) println("input: " + str) val result = (phrase(expr)(tokens)) println(result) } } }
Requirements : The String may or may not start with numeric literal. I want the output as a Array[String] or List[String] or a tuple. Also the elements should be as it is in the input, white spaces being the delimiter, like : "60","HGSSE:MSISDN=919810637917,SS=BAIC,BSG=TS10;"
Firstly, how to use combinator.ImplicitConversions with ParseResult ( created by phrase(expr) ) ? Or, is there any other way ?
Also I was not comfortable using ":", "=", ";", "-" as lexical.delimiters, when they are really not delimiters in my case. I want to write 'member' cleanly. What I have built here ( the 'member' ) is on a trial and error basis. Could you please rectify that ? How could I use a Chainl1 , if required. Please help at the earliest. I am a neophyte in Scala, and I have started coding in Scala. I have requirement to parse a little different kind of String also, about which I will let you know in the next letter.
Thanks in anticipation and with earnest regards ~ Partha Biswas