0
votes
1answer
24 views

Beginning regex

I have absolutely no idea about regex at all. I am trying to perform email validation in a PHP signup script (to check if a valid email has been entered). I have got a script from the internet but I ...
4
votes
4answers
51 views

preg_replace to insert default value when omitted

I'm trying to work on some regex for a preg_replace that would insert a default key="value" when it is not in the subject. Here's what I have: $pattern = '/\[section([^\]]+)(?!type)\]/i'; ...
0
votes
2answers
37 views

preg_replace all newlines within quotes

sorry if this seems like a simple question but I am trying to replace any newline characters that are with a quoted string e.g. $help = '"Hi this is a string and I really want to replace any newlines ...
0
votes
2answers
42 views

Remove  from string with regular expressions

I am trying to remove the following characters  from a string. However only »¿is being removed. Code: protected function removeSpecialChars($comment) { //Remove '' return ...
4
votes
1answer
47 views

Preg_replace cyrillic word or phrase - not both

I am writing a PHP function which is supposed to convert certain keywords into links. It uses Cyrillic words in UTF-8. So I came up with this: function keywords($text){ $keywords = ...
1
vote
1answer
36 views

PHP - Replacing emoticon with meaning

I am analysing informal chat style message for sentiment and other information. I need all of the emoticons to be replaced with their actual meaning, to make it easier for the system to parse the ...
0
votes
0answers
51 views

preg_replace apostrophie for words ending s using regex

Ok, so i am matching any word ending in S and replacing it with 'S for a mysql search, and all works fine.. $check = "string to tests"; if(preg_match("/s\b/", $check)) { preg_match("/s\b/", ...
2
votes
2answers
36 views

Regex compilation error [duplicate]

i am searching for a regular expression which removes an x at the beginning of a path. Accepted path separators are \, / and . The path can also start with one of these separators but it don't have ...
0
votes
1answer
40 views

Weird behavior in regular expression replacement [duplicate]

I'm doing a regular expression for a linking system, and the syntax looks like this: <a href=":login">Login</a> This tells the system that this link should be converted to JS or an HTML ...
1
vote
2answers
54 views

Replacing occurences of a specific word if not proceeded by another specific word?

I have some text like: *open* blah blah blah blah blah *close* blah blah *open* blah blah *close* blah blah *close* I was wondering how would I remove/replace any occurrences of *close* which are ...
0
votes
4answers
35 views

Regular Expression for replacing newlines

Just want to know why my regular expression is giving me 2 br tags instead of 1 when the string contains \n\r? I'm trying to replace \n, \r, \r\n and \n\r with the following: $string="testing \n\r ...
0
votes
2answers
37 views

how to replace date format in a dynamic string variable?

my variable is a dynamic string variable in this string i have some date value and looks like $var = 'bd','100','10-05-2013','20-05-2013','alise'; but i want to change this date format like $var = ...
0
votes
1answer
30 views

Grep all text following a specific format

Hi ALl i have a list that look something like so curl -x X3SzDf34 curl -x X3SzDf34r curl -a X3SzDf43 curl -x X3SzDfsdf curl -a X3SzDfsvx basically looking to grep all lines that have curl -X and to ...
0
votes
2answers
22 views

How to replace QUOTES like forums with php?

I know I should probably be using preg_replace but I'm not the best with regex. Could someone help me with the code for replacing [QUOTE=user]quote here[/QUOTE] to: ...
0
votes
1answer
36 views

Optional regex match is being ignored

I have a bit of regex in PHP that isn't doing what I want it to. What I want: [segment type="segment_name"]more text here[/segment] to be changed to: [segmentclass='segment_name segment']more ...

1 2 3 4 5 79
15 30 50 per page