Allow me to clarify my question with an illustration:
I am extracting page names from a website. The page names vary in length, for example:
- Data1|Data2|Data3
- Data1|Data2|Data3|Data4
- Data1|Data2
I need to create a Regex that will work for all of the scenarios above. Another user previously shared the following:
/(.*?)\|(.*?)\|(.*?)\|(.*)/gm;
This Regex pattern works well when there are always four groups separated by "|" and empty spaces between them. However, it fails if there are only two values. Can anyone provide guidance on how to modify this regex to handle different numbers of groups?