Reputation: 961
I am having some trouble getting this regular expression just right:
Sample string looks something like this:
"li3001easdasfsaasfasdi5ei1409529297ei1409529597ed16:acl_dec_tag_listl15:DEFAULT_CASE_11e18:avc_app_name_statsd29:Generic Search Engine Trafficd4:sizei5875e5:totali5ee16:Odnoklassniki.Rud4:sizei456e5:totali1ee7:Unknownd4:sizei6391e5:totali2ee5:Yahood4:sizei15673e5:totali1ee10:Yahoo Maild4:sizei5982e5:totali1e"
I want the string to be grouped like this:
(li<digit 1-4>e <string of varying length> i<single digit>e) (<string2 of varying length>)
This is my attempt at this regex so far: (li\d{1,}e.*i\de)(.*)
I would like only the first occurrence of li<digits 1-4>e
as well.
Upvotes: 0
Views: 605
Reputation: 1725
val s = "li3001easdasfsaasfasdi5easdasfsafas"
val p = """li(\d{1,4})e([^i]*)i(\d)(.*)""".r
val p(first,second,third,fourth) = s
results in:
first: String = 3001
second: String = asdasfsaasfasd
third: String = 5
fourth: String = easdasfsafas
Not sure if that answers your question, but hope it helps.
Upvotes: 0