I'm working on a Dart program that will parse data from an XML file. Unfortunately, the file is a bit of a mess, so I'm doing a ton of regex on it to get it into decent shape. Since Dart, like Javascript, doesn't have lookbehind functionality, I've been trying to use capturing parentheses along with the method to mimic lookbehind, to no avail. Dart doesn't like the syntax of it at all, just telling me that function
is not defined for myClass
My XML file consists of strings in the following format:
<items>Chicken Sauces/ Creamy Curried Chicken Salad w/ Wild Rice</items>
When finished, I want that string to look like:
<items>Chicken Sauces| Creamy Curried Chicken Salad w/ Wild Rice</items>
I've tried calling this on the string: .replaceAll(new RegExp(r'(\w\s*)/(?=\s*\w)'),"$0|$1")
but that gives me errors saying "Expected an identifier" for $0
and $1
. If anyone could offer me some pointers on how to properly use capturing parentheses, or a method to mimic lookbehind in Dart, along with the current lookahead, I'd be very grateful!