0

Hello,

I tried to use regex to search through

blablablablahttp://www.myspace.com/username

by using

preg_match('~http://www\.myspace\.com/.+"~',$string,$match);

The tilde or lack of was tripping me up... am I even close?
I was just trying to extract the username at the end, before it was marked off by a double quote ("). I tried adapting this answer from a previous forum post but it doesn't seem to be working. Any help would be appreciated.

Thanks,

L

2
Contributors
5
Replies
6
Views
8 Years
Discussion Span
Last Post by beginninphp
0

Thanks so much, I'll test it out and see if I can get it working, I should be able to.

0

I don't know how to tie it in to

else {

	$timeout = 300;

	ini_set('max_execution_time','120');

	set_time_limit(120);

	ini_set('default_socket_timeout','120');

	while($contents = fread($handle,'1024'))

	{ $hold .= $contents; }

above it. Could anyone tell me what function the ~ serves? I don't see it in any regex guides.

0

The tilde has no special meaning, it was just chosen as the delimiter so the slashes didn't have to be escaped. You can choose pretty much any delimiter.

$regex1 = '/http:\/\/www\.example.com\/blah/';
// vs
$regex2 = "#http://www\.example\.com/blah#';

I prefer to use / and # but it looks like the tilde was their choice.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.