I have:
|123|456|789|
I can capture only |123| using regex
\|(\d*)\|
But not sure how to capture the full string. I am quite new to this.
I will be thankful for any help
^\|(\d*\|?)*
This should work. Start with vertical bar and repeat numbers and optional vertical bar.
You can do:
^\|[\d|]*
^\| matches literal | at start, as | is a Regex token we need to escape it
[\d|]* matches any number of digits or |, | inside [] is treated literally
Demo
From comment, if there must be a | at the end, do:
^\|[\d|]*\|$
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With