mardi 4 août 2015

diffuculties with a Regex Pattern in Java

I am facing a problem regarding Regex pattern creation in order to get all the required tokens. My String value on which regex will be applied have this shape can be like this;

Value:

"DB_TABLE_LUX.field_8='bbb \' `\" dsd' and DB_TABLE_FRA.field_1 = ' bbb dsd' and DB_TABLE_FRA.fieldName = ' bbb dsd ' or DB_TABLE_GER.field_3= 125 "

Required result: I want to have a list of Strings having those values

List {

"DB_TABLE_LUX.field_8='bbb \' `\" dsd'",

"DB_TABLE__FRA.field_1 = ' bbb dsd'",

"DB_TABLE_FRA.fieldName = ' bbb dsd '",

"DB_TABLE_GER.field_3= 125" }

Following the regex used :

"DB_TABLE_[a-zA-Z]{3}\.\w+\s*\=\s*([0-9]+|(\'(\s*\w+\s*)+\'))"

The regex below is not extracting the whole data, the first values is missing and below is the result

List{

"DB_TABLE_FRA.field_1 = ' bbb dsd'",

"DB_TABLE_FRA.fieldName = ' bbb dsd '",

"DB_TABLE_GER.field_3= 125" }

I want to take into account the next value

DB_TABLE_LUX.field_8='bbb \' `\" dsd'

Thanks.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire