In javascript I use pattern:
/"(?:""|[^"])*"|[-+]?\b[0-9]*\.?[0-9]+(?:[eE][-+]?[0-9]+)?(?!&)\b/g
to extract some values from text.
var pattern = /"(?:""|[^"])*"|(?!\n)[-+]?\b[0-9]*\.?[0-9]+(?:[eE][-+]?[0-9]+)?(?!&)\b/g;
var input = "Amx = 1000: Hmx = 200\nTotal = Amx + Hmx + _\n3000\nComment = \"Payment completed\"\nWarning_\n1 Task1 is completed\n2 Task2 is uncompleted\n\n";
var values = input.match(pattern);
for (var i in values)
console.log(values[i]);
Input:
Amx = 1000: Hmx = 200
Total = Amx + Hmx + _
3000
Comment = "Payment completed"
Warning_
1 Task1 is completed
2 Task2 is uncompleted
Log:
- 1000
- 200
- 3000
- Payment completed"
- 1 (unexpected)
- 2 (unexpected)
But the result include some unexpected values (1, 2) beginning with \n. How can I solve that?