Matching lines in multiline regular expressions
1 2 3 4 5 6 7
fieldname: value anotherfieldname: anothervalue etc: somemore ---------- repeatedfieldname: newvalue mayalsobeanotherfieldname: withanothervalue ==========
The regex previously used was
with singleline and multiline flags enabled (using the Jakarta Oro PCRE compatible library).
However, it was found that some customers think their middle name is ' ----------' (even though there isn't a form anywhere on the website where one can select that), which breaks the code splitting the text above. However, a simple solution exists: to match only ten dashes or equal signs on a single line, while still capturing the groups, you can use
I think moving a single character four places is quite an elegant bugfix
BTW, the previous regex already only matched the case where a user entered exactly ten dashes, because one of the lines would then end in ten dashes, which constituted a match. The new regex only matches lines that have only ten dashes on them. No user can cause that to happen.
In other words, does it matter if you replace
After I posted this, we actually modified it to
Again, we didn't think it would work out differently; we aren't even sure there are cases in which they are different.
Comments are closed