0

Here is the java properties content

xxx_error_tx1 = This is xxxx. Johe say:
xxx_error_MapCode = xxx_error_tx1, test this function,Failed,\
               Default, Current,\
               App_Error_tx1

I need to extract string ID and string content, I can extract line1 content correctly, but the second line content extract only the first string xxx_error_tx1, test this function,Failed,\. The rest of string cannot extract.

The regex string is (?<ID>.+?)=(?<Translation>.+?)$, I know this regex have some problem, but I've tried to modify to correct pattern but maybe I am newbie, the result still cannot meet my request.

Any help would be appreciated.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Henry Hsu
  • 1
  • 3
  • possible duplicate of [Can .NET load and parse a properties file equivalent to Java Properties class?](http://stackoverflow.com/questions/485659/can-net-load-and-parse-a-properties-file-equivalent-to-java-properties-class) – Amadan Nov 25 '14 at 05:01

2 Answers2

0

Seems like you want something like this,

(?<ID>.+?)=(?<Translation>(?:(?!\S+\s*=)[\s\S])+)

DEMO

(?:(?!\S+\s*=)[\s\S])+ Matches one or more space or non-space characters which won't contain the string which was matched by this \S+\s*= pattern.

Avinash Raj
  • 172,303
  • 28
  • 230
  • 274
  • Sorry, I have other question, if the next line is a comment line xxx_error_MapCode = xxx_error_tx1, test this function,Failed,\ Default, Current,\ App_Error_tx1 # Reports The result will include the comment line, may I can use [^#] to ignore the comment line, but I don't know should I insert to which position. – Henry Hsu Nov 27 '14 at 08:50
  • Yes, very appreciate your help. – Henry Hsu Nov 27 '14 at 08:53
0

Try this, it correctly include the whole value when the value is splited on multiple lines but stop before line that follow.

(?<ID>.+?)=(?<Translation>(?:.*\\\s)*.*)

DEMO

Zartc
  • 193
  • 7