Jump to content

Regex pattern for sentence with word in


BRUm

Recommended Posts

Hi,

I'm currently coding a search engine, and everything seems to be going smoothly, until I reach regular expressions -_- (I hate them so much..). So far, the script can crawl a site from an array, and grab a sentence with the keywords. However, it's a bit messy, and I wondered if someone would be so kind as to show a pattern that would do it properly.

Basically, I need a pattern that matches a sentence with letters and numbers only (to filter out HTML) and with the sentence must have this in: [code=php:0]$pieces[0][/code]

Here's the code I'm using at the moment: [code=php:0]/$pieces[0].*/[/code] I must say it's not too good.

Any help greatly appreciated,

Thanks.
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.