I have values that have single values and concatenated values interspersed. I need to create a regular expression that will evaluate the values and return either the whole number that has no "|" or the first of a group of numbers that are separated by "|" characters.
Example
Existing values
12345667D23
3t23456
ab57890
3t23456|ab57890
12345667D23|3t23456|ab57890
Transformed values (return either the single value as same or the first of the string up to the "|")
12345667D23
3t23456
ab57890
3t23456
12345667D23
I am new to regex. I don't have enough experience here... I am not trying to match a string, just return the values (could be numerical, could be alphanumerical, there is not a set string length, just delimited by pipes)
Try this:
^[^\|]+
Here, ^
matches the start of a line, [^\|]+
matches a series of characters that aren't pipe (|
). So the whole expression matches a sequence of characters from the start of a line until |
or the end of the line.