Using this sample input:
Code:
String[] tests = new String[] { "&xf=1&gl=79", "&xf=1&gl=73", "&xf=1&gl=52&bmp=53.24", "&xf=1&gl=52",
"&xf=1&gl=127", "&xf=1&bmp=73.84", "&xf=1&bmp=65.15", "&xf=1&bmp=61.84", "&xf=1&bmp=59.48",
"&xf=1&bmp=58.56", "&xf=1&bmp=57.55", "&xf=1&bmp=55.41", "&xf=1&bmp=53.41", "&xf=1&bmp=52.99",
"&xf=1&bmp=46.23", "&xf=1", "&xf=1", "&xf=1", "&xf=1", "&xf=1", "&xf=1", "&xf=1", "&xf=1", "&xf=1", "&xf=1",
"&xf=1", "&xf=1", "&xf=1", "&xf=1", "&xf=1", "&xf=1", "&xf=1", "&xf=1", "&xf=1", "&xf=1", "&xf=1", "&xf=1",
"&xf=1", "&xf=1", "&xf=1", "&xf=1", "&xf=1", "&xf=1", "&xf=1", "&xf=1", "&xf=1", "&x=218044&xf=1",
"&x=162579&xf=1&bmp=81.93", "&x=-3000&fie=1&fit=1782&fil=52&foe=1&fot=10000",
"&x=-3000&fie=0&foe=0&xf=0&ft=40&ge=0", "&i=5994&f=160986", "&i=18759", "&i=183502&bmp=55.01", "&gl=97",
"&gl=94", "&gl=94", "&gl=94", "&gl=94", "&gl=91", "&gl=91", "&gl=85", "&gl=82", "&gl=79", "&gl=79", "&gl=76",
"&gl=-31", "&gl=-13", "&ge=0&gl=94", "&ge=0&gl=94", "&ge=0&gl=88", "&ge=0&gl=73", "&ge=0&gl=73",
"&ge=0&gl=61", "&ge=0&gl=43", "&ge=0&gl=127", "&ge=0&bmp=50.75", "&ge=0", "&ge=0", "&ge=0", "&ge=0", "&ge=0",
"&ge=0", "&ge=0", "&ge=0", "&ge=0", "&ge=0", "&ge=0", "&ge=0", "&ge=0", "&ge=0", "&ge=0", "&ge=0",
"&fot=7030&fol=100", "&fol=100", "&fol=100", "&foe=1&fot=8218&fol=100&foc=1&xf=2",
"&foe=1&fot=10000&fol=100&foc=1", "&foe=1&fol=100", "&foe=1&foc=2", "&foe=1&foc=1", "&foe=0&ge=0", "&foe=0",
"&foe=0", "&fit=9208&fil=79&fot=8218&fol=95", "&fit=0&fil=100&fic=1&ge=0",
"&fie=1&fit=990&fic=1&foe=1&fot=4653&fol=90&foc=1&g", "&fie=1&fit=8317&fil=100&fic=1&foe=1&fot=8218&fol=1",
"&fie=1&fit=10000&fil=88&fot=10000&fol=100&foc=1", "&fie=0&foe=1&fot=4950&fol=100&foc=1&ge=0&gl=25",
"&fie=0&foe=1", "&fie=0&foe=0&ge=0&gl=67", "&fie=0&foe=0&ge=0&gl=-61", "&fie=0&foe=0&ge=0", "&fie=0&foe=0",
"&fie=0&foe=0", "&fie=0&foe=0", "&fie=0&fit=500&foe=0&fot=495", "&f=99035", "&f=94281", "&f=77424",
"&ct0=36567&cn0=test", "&ct0=32685&cn0=beat&ct1=24488&cn1=vocal in",
"&ct0=175295&cn0=chorus_end&ct1=44335&cn1=early bum", "&c=9131&f=302825&fie=1&fit=10000&fil=100&fic=1",
"&c=8000", "&c=6420", "&c=6400&i=21631&ct1=13677&ct2=22380", "&c=5009&bmp=47.70", "&c=4800",
"&c=427558&fie=1&fit=8515&fil=76&fic=1", "&c=3942&bmp=59.22", "&c=3661&e=120597&bmp=63.24",
"&c=245223&i=246823&f=512225&fie=1&fit=2178&fil=80&", "&c=24386&e=180863&f=175782&x=-3000&xf=1",
"&c=234&ge=0&gl=127", "&c=230867&i=232553&f=323551", "&c=22564&e=194870&foe=1&fot=5000&fol=100",
"&c=221012&fie=1&fit=2376&fic=1", "&c=21153&bmp=47.50", "&c=201746&i=201746", "&c=19650&i=40706",
"&c=18379&i=21207&xf=1", "&c=17809&e=268510&f=261660&x=-3000&xf=1", "&c=15864&fie=1&fit=9010&fil=80&fic=1",
"&c=149166&ct1=170521", "&c=1477", "&c=1342&bmp=60.01", "&c=1200&bmp=70.67", "&c=11152", "&c=1000&xf=1",
"&c=0&gl=70", "&c=0&ct1=61345", "&c=0", "&bmp=70.34", "&bmp=67.50", "&bmp=62.90", "&bmp=62.77", "&bmp=62.68",
"&bmp=62.59", "&bmp=62.51", "&bmp=62.49", "&bmp=61.85", "&bmp=61.81", "&bmp=61.67", "&bmp=61.30",
"&bmp=61.10", "&bmp=60.50", "&bmp=60.33", "&bmp=60.02", "&bmp=59.01", "&bmp=58.71", "&bmp=58.67",
"&bmp=47.25", "&bmp=46.83", "&bmp=46.68", "&bmp=46.51", "&bmp=46.01", "&bmp=45.94", "&bmp=45.53",
"&bmp=45.47", "&bmp=45.40", "&bmp=45.24", "&bmp=45.21", "&bmp=45.14", "&bmp=45.00" };
for (String test : tests)
{
System.out.println ( "Pre : " + test );
if ( test.indexOf( "&bmp=" ) >= 0 )
{
System.out.println( "Replacement needed" );
test = test.replaceFirst( "&bmp=\\d*\\.?\\d*", "&bmp=80.88" );
}
System.out.println ( "Post: " + test );
System.out.println ( "****************************************" );
}
I get this result:
Code:
Pre : &xf=1&gl=79
Post: &xf=1&gl=79
****************************************
Pre : &xf=1&gl=73
Post: &xf=1&gl=73
****************************************
Pre : &xf=1&gl=52&bmp=53.24
Replacement needed
Post: &xf=1&gl=52&bmp=80.88
****************************************
Pre : &xf=1&gl=52
Post: &xf=1&gl=52
****************************************
Pre : &xf=1&gl=127
Post: &xf=1&gl=127
****************************************
Pre : &xf=1&bmp=73.84
Replacement needed
Post: &xf=1&bmp=80.88
****************************************
Pre : &xf=1&bmp=65.15
Replacement needed
Post: &xf=1&bmp=80.88
****************************************
Pre : &xf=1&bmp=61.84
Replacement needed
Post: &xf=1&bmp=80.88
****************************************
Pre : &xf=1&bmp=59.48
Replacement needed
Post: &xf=1&bmp=80.88
****************************************
Pre : &xf=1&bmp=58.56
Replacement needed
Post: &xf=1&bmp=80.88
****************************************
Pre : &xf=1&bmp=57.55
Replacement needed
Post: &xf=1&bmp=80.88
****************************************
Pre : &xf=1&bmp=55.41
Replacement needed
Post: &xf=1&bmp=80.88
****************************************
Pre : &xf=1&bmp=53.41
Replacement needed
Post: &xf=1&bmp=80.88
****************************************
Pre : &xf=1&bmp=52.99
Replacement needed
Post: &xf=1&bmp=80.88
****************************************
Pre : &xf=1&bmp=46.23
Replacement needed
Post: &xf=1&bmp=80.88
****************************************
Pre : &xf=1
Post: &xf=1
****************************************
Pre : &xf=1
Post: &xf=1
****************************************
Pre : &xf=1
Post: &xf=1
****************************************
Pre : &xf=1
Post: &xf=1
****************************************
Pre : &xf=1
Post: &xf=1
****************************************
Pre : &xf=1
Post: &xf=1
****************************************
Pre : &xf=1
Post: &xf=1
****************************************
Pre : &xf=1
Post: &xf=1
****************************************
Pre : &xf=1
Post: &xf=1
****************************************
Pre : &xf=1
Post: &xf=1
****************************************
Pre : &xf=1
Post: &xf=1
****************************************
Pre : &xf=1
Post: &xf=1
****************************************
Pre : &xf=1
Post: &xf=1
****************************************
Pre : &xf=1
Post: &xf=1
****************************************
Pre : &xf=1
Post: &xf=1
****************************************
Pre : &xf=1
Post: &xf=1
****************************************
Pre : &xf=1
Post: &xf=1
****************************************
Pre : &xf=1
Post: &xf=1
****************************************
Pre : &xf=1
Post: &xf=1
****************************************
Pre : &xf=1
Post: &xf=1
****************************************
Pre : &xf=1
Post: &xf=1
****************************************
Pre : &xf=1
Post: &xf=1
****************************************
Pre : &xf=1
Post: &xf=1
****************************************
Pre : &xf=1
Post: &xf=1
****************************************
Pre : &xf=1
Post: &xf=1
****************************************
Pre : &xf=1
Post: &xf=1
****************************************
Pre : &xf=1
Post: &xf=1
****************************************
Pre : &xf=1
Post: &xf=1
****************************************
Pre : &xf=1
Post: &xf=1
****************************************
Pre : &xf=1
Post: &xf=1
****************************************
Pre : &xf=1
Post: &xf=1
****************************************
Pre : &x=218044&xf=1
Post: &x=218044&xf=1
****************************************
Pre : &x=162579&xf=1&bmp=81.93
Replacement needed
Post: &x=162579&xf=1&bmp=80.88
****************************************
Pre : &x=-3000&fie=1&fit=1782&fil=52&foe=1&fot=10000
Post: &x=-3000&fie=1&fit=1782&fil=52&foe=1&fot=10000
****************************************
Pre : &x=-3000&fie=0&foe=0&xf=0&ft=40&ge=0
Post: &x=-3000&fie=0&foe=0&xf=0&ft=40&ge=0
****************************************
Pre : &i=5994&f=160986
Post: &i=5994&f=160986
****************************************
Pre : &i=18759
Post: &i=18759
****************************************
Pre : &i=183502&bmp=55.01
Replacement needed
Post: &i=183502&bmp=80.88
****************************************
Pre : &gl=97
Post: &gl=97
****************************************
Pre : &gl=94
Post: &gl=94
****************************************
Pre : &gl=94
Post: &gl=94
****************************************
Pre : &gl=94
Post: &gl=94
****************************************
Pre : &gl=94
Post: &gl=94
****************************************
Pre : &gl=91
Post: &gl=91
****************************************
Pre : &gl=91
Post: &gl=91
****************************************
Pre : &gl=85
Post: &gl=85
****************************************
Pre : &gl=82
Post: &gl=82
****************************************
Pre : &gl=79
Post: &gl=79
****************************************
Pre : &gl=79
Post: &gl=79
****************************************
Pre : &gl=76
Post: &gl=76
****************************************
Pre : &gl=-31
Post: &gl=-31
****************************************
Pre : &gl=-13
Post: &gl=-13
****************************************
Pre : &ge=0&gl=94
Post: &ge=0&gl=94
****************************************
Pre : &ge=0&gl=94
Post: &ge=0&gl=94
****************************************
Pre : &ge=0&gl=88
Post: &ge=0&gl=88
****************************************
Pre : &ge=0&gl=73
Post: &ge=0&gl=73
****************************************
Pre : &ge=0&gl=73
Post: &ge=0&gl=73
****************************************
Pre : &ge=0&gl=61
Post: &ge=0&gl=61
****************************************
Pre : &ge=0&gl=43
Post: &ge=0&gl=43
****************************************
Pre : &ge=0&gl=127
Post: &ge=0&gl=127
****************************************
Pre : &ge=0&bmp=50.75
Replacement needed
Post: &ge=0&bmp=80.88
****************************************
Pre : &ge=0
Post: &ge=0
****************************************
Pre : &ge=0
Post: &ge=0
****************************************
Pre : &ge=0
Post: &ge=0
****************************************
Pre : &ge=0
Post: &ge=0
****************************************
Pre : &ge=0
Post: &ge=0
****************************************
Pre : &ge=0
Post: &ge=0
****************************************
Pre : &ge=0
Post: &ge=0
****************************************
Pre : &ge=0
Post: &ge=0
****************************************
Pre : &ge=0
Post: &ge=0
****************************************
Pre : &ge=0
Post: &ge=0
****************************************
Pre : &ge=0
Post: &ge=0
****************************************
Pre : &ge=0
Post: &ge=0
****************************************
Pre : &ge=0
Post: &ge=0
****************************************
Pre : &ge=0
Post: &ge=0
****************************************
Pre : &ge=0
Post: &ge=0
****************************************
Pre : &ge=0
Post: &ge=0
****************************************
Pre : &fot=7030&fol=100
Post: &fot=7030&fol=100
****************************************
Pre : &fol=100
Post: &fol=100
****************************************
Pre : &fol=100
Post: &fol=100
****************************************
Pre : &foe=1&fot=8218&fol=100&foc=1&xf=2
Post: &foe=1&fot=8218&fol=100&foc=1&xf=2
****************************************
Pre : &foe=1&fot=10000&fol=100&foc=1
Post: &foe=1&fot=10000&fol=100&foc=1
****************************************
Pre : &foe=1&fol=100
Post: &foe=1&fol=100
****************************************
Pre : &foe=1&foc=2
Post: &foe=1&foc=2
****************************************
Pre : &foe=1&foc=1
Post: &foe=1&foc=1
****************************************
Pre : &foe=0&ge=0
Post: &foe=0&ge=0
****************************************
Pre : &foe=0
Post: &foe=0
****************************************
Pre : &foe=0
Post: &foe=0
****************************************
Pre : &fit=9208&fil=79&fot=8218&fol=95
Post: &fit=9208&fil=79&fot=8218&fol=95
****************************************
Pre : &fit=0&fil=100&fic=1&ge=0
Post: &fit=0&fil=100&fic=1&ge=0
****************************************
Pre : &fie=1&fit=990&fic=1&foe=1&fot=4653&fol=90&foc=1&g
Post: &fie=1&fit=990&fic=1&foe=1&fot=4653&fol=90&foc=1&g
****************************************
Pre : &fie=1&fit=8317&fil=100&fic=1&foe=1&fot=8218&fol=1
Post: &fie=1&fit=8317&fil=100&fic=1&foe=1&fot=8218&fol=1
****************************************
Pre : &fie=1&fit=10000&fil=88&fot=10000&fol=100&foc=1
Post: &fie=1&fit=10000&fil=88&fot=10000&fol=100&foc=1
****************************************
Pre : &fie=0&foe=1&fot=4950&fol=100&foc=1&ge=0&gl=25
Post: &fie=0&foe=1&fot=4950&fol=100&foc=1&ge=0&gl=25
****************************************
Pre : &fie=0&foe=1
Post: &fie=0&foe=1
****************************************
Pre : &fie=0&foe=0&ge=0&gl=67
Post: &fie=0&foe=0&ge=0&gl=67
****************************************
Pre : &fie=0&foe=0&ge=0&gl=-61
Post: &fie=0&foe=0&ge=0&gl=-61
****************************************
Pre : &fie=0&foe=0&ge=0
Post: &fie=0&foe=0&ge=0
****************************************
Pre : &fie=0&foe=0
Post: &fie=0&foe=0
****************************************
Pre : &fie=0&foe=0
Post: &fie=0&foe=0
****************************************
Pre : &fie=0&foe=0
Post: &fie=0&foe=0
****************************************
Pre : &fie=0&fit=500&foe=0&fot=495
Post: &fie=0&fit=500&foe=0&fot=495
****************************************
Pre : &f=99035
Post: &f=99035
****************************************
Pre : &f=94281
Post: &f=94281
****************************************
Pre : &f=77424
Post: &f=77424
****************************************
Pre : &ct0=36567&cn0=test
Post: &ct0=36567&cn0=test
****************************************
Pre : &ct0=32685&cn0=beat&ct1=24488&cn1=vocal in
Post: &ct0=32685&cn0=beat&ct1=24488&cn1=vocal in
****************************************
Pre : &ct0=175295&cn0=chorus_end&ct1=44335&cn1=early bum
Post: &ct0=175295&cn0=chorus_end&ct1=44335&cn1=early bum
****************************************
Pre : &c=9131&f=302825&fie=1&fit=10000&fil=100&fic=1
Post: &c=9131&f=302825&fie=1&fit=10000&fil=100&fic=1
****************************************
Pre : &c=8000
Post: &c=8000
****************************************
Pre : &c=6420
Post: &c=6420
****************************************
Pre : &c=6400&i=21631&ct1=13677&ct2=22380
Post: &c=6400&i=21631&ct1=13677&ct2=22380
****************************************
Pre : &c=5009&bmp=47.70
Replacement needed
Post: &c=5009&bmp=80.88
****************************************
Pre : &c=4800
Post: &c=4800
****************************************
Pre : &c=427558&fie=1&fit=8515&fil=76&fic=1
Post: &c=427558&fie=1&fit=8515&fil=76&fic=1
****************************************
Pre : &c=3942&bmp=59.22
Replacement needed
Post: &c=3942&bmp=80.88
****************************************
Pre : &c=3661&e=120597&bmp=63.24
Replacement needed
Post: &c=3661&e=120597&bmp=80.88
****************************************
Pre : &c=245223&i=246823&f=512225&fie=1&fit=2178&fil=80&
Post: &c=245223&i=246823&f=512225&fie=1&fit=2178&fil=80&
****************************************
Pre : &c=24386&e=180863&f=175782&x=-3000&xf=1
Post: &c=24386&e=180863&f=175782&x=-3000&xf=1
****************************************
Pre : &c=234&ge=0&gl=127
Post: &c=234&ge=0&gl=127
****************************************
Pre : &c=230867&i=232553&f=323551
Post: &c=230867&i=232553&f=323551
****************************************
Pre : &c=22564&e=194870&foe=1&fot=5000&fol=100
Post: &c=22564&e=194870&foe=1&fot=5000&fol=100
****************************************
Pre : &c=221012&fie=1&fit=2376&fic=1
Post: &c=221012&fie=1&fit=2376&fic=1
****************************************
Pre : &c=21153&bmp=47.50
Replacement needed
Post: &c=21153&bmp=80.88
****************************************
Pre : &c=201746&i=201746
Post: &c=201746&i=201746
****************************************
Pre : &c=19650&i=40706
Post: &c=19650&i=40706
****************************************
Pre : &c=18379&i=21207&xf=1
Post: &c=18379&i=21207&xf=1
****************************************
Pre : &c=17809&e=268510&f=261660&x=-3000&xf=1
Post: &c=17809&e=268510&f=261660&x=-3000&xf=1
****************************************
Pre : &c=15864&fie=1&fit=9010&fil=80&fic=1
Post: &c=15864&fie=1&fit=9010&fil=80&fic=1
****************************************
Pre : &c=149166&ct1=170521
Post: &c=149166&ct1=170521
****************************************
Pre : &c=1477
Post: &c=1477
****************************************
Pre : &c=1342&bmp=60.01
Replacement needed
Post: &c=1342&bmp=80.88
****************************************
Pre : &c=1200&bmp=70.67
Replacement needed
Post: &c=1200&bmp=80.88
****************************************
Pre : &c=11152
Post: &c=11152
****************************************
Pre : &c=1000&xf=1
Post: &c=1000&xf=1
****************************************
Pre : &c=0&gl=70
Post: &c=0&gl=70
****************************************
Pre : &c=0&ct1=61345
Post: &c=0&ct1=61345
****************************************
Pre : &c=0
Post: &c=0
****************************************
Pre : &bmp=70.34
Replacement needed
Post: &bmp=80.88
****************************************
Pre : &bmp=67.50
Replacement needed
Post: &bmp=80.88
****************************************
Pre : &bmp=62.90
Replacement needed
Post: &bmp=80.88
****************************************
Pre : &bmp=62.77
Replacement needed
Post: &bmp=80.88
****************************************
Pre : &bmp=62.68
Replacement needed
Post: &bmp=80.88
****************************************
Pre : &bmp=62.59
Replacement needed
Post: &bmp=80.88
****************************************
Pre : &bmp=62.51
Replacement needed
Post: &bmp=80.88
****************************************
Pre : &bmp=62.49
Replacement needed
Post: &bmp=80.88
****************************************
Pre : &bmp=61.85
Replacement needed
Post: &bmp=80.88
****************************************
Pre : &bmp=61.81
Replacement needed
Post: &bmp=80.88
****************************************
Pre : &bmp=61.67
Replacement needed
Post: &bmp=80.88
****************************************
Pre : &bmp=61.30
Replacement needed
Post: &bmp=80.88
****************************************
Pre : &bmp=61.10
Replacement needed
Post: &bmp=80.88
****************************************
Pre : &bmp=60.50
Replacement needed
Post: &bmp=80.88
****************************************
Pre : &bmp=60.33
Replacement needed
Post: &bmp=80.88
****************************************
Pre : &bmp=60.02
Replacement needed
Post: &bmp=80.88
****************************************
Pre : &bmp=59.01
Replacement needed
Post: &bmp=80.88
****************************************
Pre : &bmp=58.71
Replacement needed
Post: &bmp=80.88
****************************************
Pre : &bmp=58.67
Replacement needed
Post: &bmp=80.88
****************************************
Pre : &bmp=47.25
Replacement needed
Post: &bmp=80.88
****************************************
Pre : &bmp=46.83
Replacement needed
Post: &bmp=80.88
****************************************
Pre : &bmp=46.68
Replacement needed
Post: &bmp=80.88
****************************************
Pre : &bmp=46.51
Replacement needed
Post: &bmp=80.88
****************************************
Pre : &bmp=46.01
Replacement needed
Post: &bmp=80.88
****************************************
Pre : &bmp=45.94
Replacement needed
Post: &bmp=80.88
****************************************
Pre : &bmp=45.53
Replacement needed
Post: &bmp=80.88
****************************************
Pre : &bmp=45.47
Replacement needed
Post: &bmp=80.88
****************************************
Pre : &bmp=45.40
Replacement needed
Post: &bmp=80.88
****************************************
Pre : &bmp=45.24
Replacement needed
Post: &bmp=80.88
****************************************
Pre : &bmp=45.21
Replacement needed
Post: &bmp=80.88
****************************************
Pre : &bmp=45.14
Replacement needed
Post: &bmp=80.88
****************************************
Pre : &bmp=45.00
Replacement needed
Post: &bmp=80.88
****************************************
Looks good to me.