This is a sample piece from a huge file containing formula and bio code. Some lines starts with the following characters:
Sheep"-head`ed, // followed by some normal words
Mon`o*car*bon"ic, // followed by some normal words
mon`o*car"di*an, // followed by some normal words
Pol`y*chro"mate, // followed by some normal words
sheep"cot`, // followed by some normal words
baad, // followed by some normal words
I am new in regular expression. Now I am trying to use TPerlRegEx (a wrapper of PCRE library). I need to extract:
Sheep"-head`ed,
Mon`o*car*bon"ic,
mon`o*car"di*an,
Pol`y*chro"mate,
sheep"cot`,
baad,
Can you help me write a regular expression?
Many thanks.
Edit:
Thank all for help. If a normal is between them:
Sheep"-head`ed, // followed by some normal words
Mon`o*car*bon"ic, // followed by some normal words
New test, //I do not want two or more than two words that end with comma.
mon`o*car"di*an, // followed by some normal words
Pol`y*chro"mate, // followed by some normal words
sheep"cot`, // followed by some normal words
baad, // I want this one word that ends with comma
I still want:
Sheep"-head`ed,
Mon`o*car*bon"ic,
mon`o*car"di*an,
Pol`y*chro"mate,
sheep"cot`,
baad, // I want this ONE word that ends with comma.
Thank you again.
The raw regex is
^[^,]+,regex in perl:/^[^,]+,/^matches beginning of line[^ ,]+matches as many non-commas,non-spaces as possible.,matches the comma