Extract specific string from a text

0
Hello everyone, I am working on twitter api to fetch data based on recent search...I am able to fetch the tweet id and text but I want to extract the username that is mentioned in the text  field...Can anyone help me out with it!!!   Regards, Chetan Ghodke
asked
1 answers
1

In the string the username is probably preceded with fixed set of characters and followed with a fixed number of characters. Use

findAll('precedingtext', $YourVariableIncludingTheUsername)

and

findAll('followingtext', $YourVariableIncludingTheUsername)

to get the first and last position of the username. Then use

substring($YourVariableIncludingTheUsername, $PositionFirstCharacter, $PositionLastCharacter)

 

answered