Welcome Guest, Not a member yet? Register   Sign In
preg match @ sign
#1

[eluser]new_igniter[/eluser]
I am new to preg match but hoping someone could help me write a reg ex that would do something like the following:
I want to parse twitter feeds and pull out the content when someone posts "at" someone. This always begins with the @ sign then the name, and then the content.

How do I write something like "look for the at sign, then copy everything until there is a space after the name.

I am using get file contents, so the actual html looks like this
@<a href="/ev">ev</a>
#2

[eluser]Pascal Kriete[/eluser]
Should be pretty simple. Maybe something like this:
Code:
// Get text from twitter
$text = get_twitter_text_here();

// Don't need linkage
$text = strip_tags($text);

// Pattern
$pattern = '/@(?<name>\w+) /';

// And find it
preg_match ($pattern , $text, $matches);

// Get our named subpattern
$name = $matches['name'];




Theme © iAndrew 2016 - Forum software by © MyBB