java - Regex match and substitute strings of special look -


i have set of strings this:

"ak pz 310u pi-13-5","23.02.2015","07:45:00","23.02.2015","09:20:00","false","true","23.02.2015","07:40:00","2","common","ak pz 310u pi-13-5","common" 

and using 1 single regex , replaceall method need exactly following string:

2015-02-23 ==> 07:45 ak pz 310u 

i have regex matches time , date

((0[1-9]|[12][0-9]|3[01])\.(0[1-9]|1[012])\.\d\d\d\d)|((([0-1][0-9])|([2][0-3])):([0-5][0-9]):([0-5][0-9])) 

i think should somehow make use of capturing groups. part of string: "ak pz 310u pi-13-5" starts capital letter , finishes number between 1 , 6, think it's quite trivial match one. how substitute regex matches needed look? , how can insert ==> sign string.replaceall method? ideas?

btw: probably, if original task difficult, can create two-dimensional array of particular capturing groups in regex , manipulate output. maybe can throw me hint on how this?

here regex101.com link https://regex101.com/r/vt7ek2/3

for php world recommend regexp:

#^"(\w+) (\w+) (\w+) (?:.+?)","(\d+)\.(\d+)\.(\d+)","(\d+):(\d+):(\d+)"(?:.*?)$#i 

and replacement pattern:

$6-$5-$4 ==> $7:$8 $1 $2 $3 

i've tested on site https://ru.functions-online.com/preg_replace.html

i think not difficult translate php_replace regexp java regexp


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -