Reputation: 379
I am stumped working on a regular expression. So here is the sample text I am working with to run my regex on.
21;#ABC - A8 (ZYWX) DEF - S123 CODE ASD4 - PL_MN - 567aB - 987aL 6.8R WHHHA StackOverflow.file;42;#ABC_9876f_KIIIt_QW_blew34.files;43;#ABC-LKP RT00-44-33 [email protected];45;#Javax_P3_2345_123lE_451rP_Regex_Expression_Help.rewa;26;#GHJ - AQS 231-4_330-9 TIIIx Python JavaScript.text;
Here is the end result I am looking for after running the regex:
ABC - A8 (ZYWX) DEF - S123 CODE ASD4 - PL_MN - 567aB - 987aL 6.8R WHHHA StackOverflow
ABC_9876f_KIIIt_QW_blew34
ABC-LKP RT00-44-33 876aY@2200foo
Javax_P3_2345_123lE_451rP_Regex_Expression_Help
GHJ - AQS 231-4_330-9 TIIIx Python JavaScript
A total of 5 matches.
The regular expression I have thus far is:
[A-Z][()\w\s@-]*
This regex isn't working though because the first line in my results ends up getting split in two pieces at the period. I am unable to come up with a solution as to how to fix this. I am fairly new to regex so any help would be appreciated. Thank you.
Upvotes: 0
Views: 46
Reputation: 782693
It looks like each match ends with .
, followed by a word, followed by ;
. Use a positive lookahead to match a string followed by that.
[A-Z][()\w\s@\-.]*(?=\.\w+;)
Upvotes: 1