I am creating a program which will reformat an XML file.
e.g.; The following is the XML snippet.
<ServiceRequest actionCode=KK
addedWithoutItinerary=false airlineCode=1S
code=ADTK orderNumber=1 serviceCount=1
serviceType=SSR ssrType=AFX>
I want to surround all attribute values with double quotes.
e.g.;
<ServiceRequest actionCode="KK"
addedWithoutItinerary="false" airlineCode="1S"
code="ADTK" orderNumber="1" serviceCount="1"
serviceType="SSR" ssrType="AFX">
Hence, I am trying to write a REGEX Pattern which can serve the purpose.
I want to extract all text strings between = and single whitespace character ("\s"), like "=false ", "=1S " and so on.
I tried this Pattern
private static final Pattern ATTR_PATTERN = Pattern.compile("(?<==)(.*)(?= |\\n)");
but this Pattern is grouping all texts which has ending character as whitespace.
e.g.;
KK
addedWithoutItinerary=false airlineCode=1S
code=ADTK orderNumber=1 serviceCount=1
serviceType=SSR
Any suggestion?