Jump to content

Pattern for Alpha and - symbol only...


Bottyz

Recommended Posts

Hi all,

 

 

I'm very new to regex and cannot get my head around all the characters. I've been testing out a few things to work it out but am struggling with one in particular.

 

I've created a news system for my website in php and on the main page you only have a truncated description of each article but with 'read more' links to the full article. The 'read more' links like news.php?article=

 

Where it has the ?article= it has a meaning full seo friendly title such as "new-website" or "news-page-launched" etc.... This link then brings up that full article.

 

My idea is to use a preg_match expression that makes sure all that is in the link is letters and the - symbol. This is to make sure no-one can insert code here and attack the site.

 

Is this a bad idea or can anyone help?

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.