php split string using regex -
I need to get company name and it's a ticker symbol in different arrays. Here is my data that is stored in a txt file:
3M company MMM 99 cents Store Only NDN AO Smith Corporation AOS Aaron, Inc. An and so on
How could I use this regex or some other techniques? Thanks
Repeat from each line, and collect data with regular expression:
^ (. +?) \ S + ([AZ] +) $
The name of the company will be the name of the backtraper $ 1 , $ 2 will signify a ticker in
You can split the string with two or three-space delimiter in two and trim the resultant two strings. It works only if you make sure the company's name and ticker mark are always separated from the adequate space, and that company does not have the amount of space in that name.
Comments
Post a Comment