preg-match

Warning: preg_match() [function.preg-match]: Unknown modifier '/' -- I would like help to fix this problem.

I'm trying to use preg_match to return all the URL's that are inclosed in " " in a page source code. The code I am using is preg_match('"http://(.+?)\"', $code, $matches); And I am getting the following error: Warning: preg_match() [function.preg-match]: Unknown modifier '/' in .... on line 13 Please help me. This is driving me m...

Regular expression needed for date/time validation

I need a PHP 5 regular expression for the following date/time format: 10 Jul 2010 15:00 (2 digits space 3 characters space 4 digits space 2 digits colon 2 digits) Character case does not matter, and the only allowed input is a-z, 0-9, space, colon Thanks in advance. ...

Simple regular expression to get text between <br/> and next <br/>

I have a string that contains this (and another things): <b>SINOPSIS:</b><br/> Text text text and mooore text...<br/> I need a reg-ex to get the text between those first two <br/> tags. Thanks... Note: There are more <br/> tags. I need the first occurrence only.. I will be using PHPs preg_match() function. ...

Regular Expression - Small change needed

I need a regular expression that will allow only a to z and 0 to 9. I came across the function below on this site, but it allows a few symbols thru (#.-). How should it be done if it has to allow only a to z (both upper and lower case) and 0 to 9? I'm scared to edit it since I know nothing about regular expressions. Also is this regular...

preg_match() and username

function isUserID($username) { if (preg_match('/^[a-z\d_]{2,20}$/i', $username)) { return true; } else { return false; } } Easy one.., i have this, can you explain what it checks for? I know it checks if the username have length between 2-20, what more? Thanks ...

php capture group

Hi, Im kind of stuck capturing a group with preg_match() in php. This is my pattern: <ns2:uniqueIds>(.*)<\/ns2:uniqueIds> And this is the source: <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"&gt;&lt;env:Header/&gt;&lt;env:Body&gt;&lt;ns2:ListResponse xmlns:ns2="http://censored"&gt;&lt;ns2:uniqueIds&gt;censored&l...

Using preg_replace/ preg_match with UTF-8 characters - specifically Māori macrons

I'm writing some autosuggest functionality which suggests page names that relate to the terms entered in the search box on our website. For example typing in "rubbish" would suggest "Rubbish & Recycling", "Rubbish Collection Centres" etc. I am running into a problem that some of our page names include macrons - specifically the macron ...

preg_match help

Hi! I'm using preg_match for the first time but I'm stuck even before I got some code... With the help from RegExr I have figured out that I need to use this expression: /\(.*M\)\s.*?:/gm What I need help with is how I gonna use this to place<b></b>around the matched text. Gratefull for help. ...

php preg_match grab out

<script type="text/javascript"><!-- Vertical1_437 = "false-2010"; ShowAdHereBanner1437 =" true"; RepeatAll1437 = "true"; NoFollowAll1437 ="true"; //--> </script> I'm trying to get the 2010 part out of the false-2010. i want it to echo 2010 only.. Thanks for the help. this was what i started with and got stuck <?php $get2010 = pr...

validate username, password and email with php

Hi. I am working on validating username, pass and email with php. I need to be sure I get it right so nobody can bypass the login page. This is the values: $email=$_POST['email']; $username=$_POST['uname']; $passwd=$_POST['pass']; $passwd2=$_POST['passcopy']; So far I have email validation: if(!(preg_match("/^[\.A-z0-9_\-\+]+[@][A-...

preg_match post-id

I'm trying to get the post-id my posts. this is the format it is in--> postid-785645 the numbers are randomly generated. <?php $mysite = "http://example.com"; $wholepage = @file_get_contents($mysite); // I want to use preg_match to echo just the numbers. out of the whole page. // Basically i'm trying to have is search the whole page fo...

PHP Regex for splitting a string at the first occurrence of a character.

This may be a lame question but I am a total novice with regular expressions. I have some text data in the format: Company Name: Name of the company, place. Company Address: Some, address, here. Link: http://www.somelink.com Now, I want to use a regex to split these into an array of name : value pairs. The regular expression...

Regex in PHP between /* & */ for preg-match

I am trying to extract all substrings in a string that is between the strings /* and */. I know this will probably need to be done with regular expressions however I'm having a hard time getting the correct regex since the star character is actually used to symbolise repeated characters. I'm am trying to use the preg-match method in PHP ...

What is wrong with this regular expression?

I'm trying to learn some basic regular expression and having a hard time getting it to work. What is wrong with this? if (preg_match("[a-zA-Z0-9]{1,}", $url)) { It must be something to do with my technique since I can hardly get any examples to work. ...

Function ereg() is deprecated

I'm going through my code to replace any instances I'm using the ereg() function - which I was using for matching regex inside a string. I could use a little direction, if someone has a better method than what I'm using. Here's my old "currency validation" script: function valid_currency($number){ if(ereg('^[0-9]+\.[0-9]{2}$'...

preg_match: ensure the start and the end contains something

Hi, I want to have the regular expression that makes sure the beginning of the string contains 'http://' and '/' and the end. This is a longer version I came up with, if(!preg_match("/(^http:\/\//", $site_http)) { $error = true; echo '<error elementid="site_http" message="site_http - Your link appears to be invalid. Please confirm ...

Embed code regular expression won't work

I have a regular expression that I have written in order to extract values that a user enters and replace some height and width values and keep the urls. This is so it can be safely added to a database. This is what I have so far (just trying to get the preg_match to return a TRUE value) $test ='<object height="81" width="100%"> <param...

verify string with preg_match

Hi all, I have question that seems simple to you all but can't really get it. encounter warning till now. May I know how can i accept a string with integers 0-9 and alpha a-zA-Z but minimum 5 characters and maximum 15 characters with preg_match. Thanks ...

Number replace pattern issue with RegEx

I have the string page-24 and want to replace 24 by any other number. The script is written in PHP and uses preg_replace, however this problem should be independent from the programming language. My match pattern is: (.*-)(\d*) The replace pattern would be: $1[insert number here]$2 The backreferences work, but I cannot insert a numbe...

Trouble using indexed arrays with preg_replace() PHP

Hi there. First time i post here and hope somebody will be able to help me. I have a file whos numbering starts at 610 and goes on to 1019. I want to use PHP's preg_match() function to start the numbering from 0 and go on till 410. Here is some code i've been working on. But i cant get the function to replace the numbers. I don't know ...