Jump to content

[SOLVED] dont know what a couple things mean...


mike12255

Recommended Posts

So this line of code has everything in it i need to know.

 

#\[b\](.*?)\[/b\]#is'

 

First thing i don't know is why the # symbol is at the beginning what does it do?

Second thing i dont know is the (.*?) i take it it means and or something of that sorts?

and the last thing i dont understand is the #is what does that do?

 

Thanks for any help given :)

Link to comment
Share on other sites

so does it give  (.*?) the value of $1?

 

im loooking off this example:

 

	$format_search =  array('#\[b\](.*?)\[/b\]#is', // Bold ([b]text[/b]
			'#\[i\](.*?)\[/i\]#is', // Italics ([i]text[/i]
			'#\[u\](.*?)\[/u\]#is', // Underline ([u]text[/u])
			'#\[s\](.*?)\[/s\]#is', // Strikethrough ([s]text[/s])
			'#\[quote\](.*?)\[/quote\]#is', // Quote ([quote]text[/quote])
			'#\[size=([1-9]|1[0-9]|20)\](.*?)\[/size\]#is', // Font size 1-20px [size=20]text[/size])
			'#\[color=\#?([A-F0-9]{3}|[A-F0-9]{6})\](.*?)\[/color\]#is', // Font color ([color=#00F]text[/color])
			'#\[url=(.*?)\](.*?)\[/url\]#i', // Hyperlink with descriptive text ([url=http://url]text[/url])
			'#\[url\](.*?)\[/url\]#i', // Hyperlink ([url]http://url[/url])
			'#\[img\](.*?)\[/img\]#i'); // Image ([img=http://url_to_image])
// The matching array of strings to replace matches with
$format_replace = array('<strong>$1</strong>',
			'<em>$1</em>',
			'<span style="text-decoration: underline;">$1</span>',
			'<span style="text-decoration: line-through;">$1</span>',
			'<blockquote>$1</blockquote>',
			'<pre>$1</'.'pre>',
			'<span style="font-size: $1px;">$2</span>',
			'<span style="color: #$1;">$2</span>',
			'<a href="$1">$2</a>',
			'<a href="$1">$1</a>',
			'<img src="$1" alt="" />');

Link to comment
Share on other sites

Mostly right.  .*? is just some arbitrary pattern.  The important part is the parenthesis.  Any pattern can be inside the parenthesis.  You can even have captures nested inside of captures.  The variables $1, $2, $3, etc... populate in order of parenthesis appearance, from left to right. 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.