I am parsing a html document.. and i am finally to the point where, i need to check for lines that might contain symbols (1 or many)
AAPL, GOOG, MSFT
AAPL
GE
GE, NVDA, IBM, CRM
As you can see the lines could contain one or more symbols (delimeted by comma’s).. how can i check the line to check if satisifies above criteria? (i.e. to check whether one or more symbols are in that specific line being processed)
my first stab at it – which doesnt seem to work (since the line with all the symbols are usually below 20 characters)..
if($checkforcompanysymbol =~ m/^[a-z0-9]{0,20}$?/)
Try this
See it online here on Regexr
^match the start of the string[A-Z]character class, match any char from the range A-Z[A-Z]{1,4}match 1-4 characters from the character class(?:,\s?[A-Z]{1,4})*(?: ...)is a non capturing group,,\s?is a comma followed by an optional whitespace, 1-4 chars and all this 0 or more times (because of the*).$matches the end of the string