I have a string in the form
|a Some text, letters or numbers. | Some other text letters or numbers |b some other part of text |c some other letters or numbers
notice the bar can be on its own, as in "numbers. | Some other" or with a character "|a", "|b", "|c", and so on, potentially through to "|z"
but this could also be
|a Title without any other bars
In other words the number of bars is unknown.
I need to find two regular expressions to use with sed:
- The first, finds all text between |a and |b, or |b and |c, and so on
in 1), for example,
find all text after a| but before b|, yielding:
Some text, letters or numbers. | Some other text letters or numbers
find all text after b| but before c|, yielding, in the example above:
Some other part of text
- A second expression is needed to find all text after |a, but, rather than stopping at |b, simply deletes any bars, on their own (|), or with another character |a, |b, |c, etc.
in 1) for example:
Some text, letters or numbers Some other text letters or numbers some other part of text some other letters or numbers