1
vote
2answers
21 views

Passing an URL as a paramter using URL rewriting (apache)

I have created a .htaccess file in which I try to rewrite certain URL's. My goals is to pass an URL to another script as a parameter. It kind of works, but I end up with URL's that only contain one ...
0
votes
3answers
42 views

PHP how to retrieve a string inbetween 2 characters? [duplicate]

I'm having trouble with this, I did find a couple of reg ex examples but I can't seem to get them to work for me. $string = '1. A post-hardcore band from Brazil 2. A rock band from Sweden'; I need ...
0
votes
1answer
20 views

PHP Regex does not match special characters

I have a old script for password encryption which I'm trying to bring back to life. This script is responsible for encryption/decryption for RSA Public Key. The code I'm presenting here is ...
0
votes
0answers
38 views

How to get data from a table on a webpage in PHP

I am trying to get data from four rows each with two rows from a webpage. After some reading around I have tried the following code; <?PHP require('simple_html_dom.php'); $ch = curl_init(); ...
3
votes
2answers
38 views

PHP - A better way to get these values?

$image= "some-name-of-my-image-640x480-123.jpg" I need to extract 640x480 and 123. What is working for me right now is: list($dirname, $basename, $extension, $filename) = ...
0
votes
0answers
20 views

Using regex with Elastica

I have been using elastisearch trough elastica recently and I am having problems using the regexp. Here is my problem: I need to find all instances of my "Foo" entity with the "name" NOT begin by a ...
-3
votes
2answers
31 views

Regular Expression with PHP [on hold]

I have a string that looks like this "Some text with things in it This mail is sent via contact form on http://domain.com/file.php" I want a regular expression to get domain.com only from the ...
1
vote
1answer
19 views

Split string by multiple (more specific) delimiters in PHP

I know this question has been asked a million times, though I can't really find the answer for my question. I read the answer from this question How to split a string by multiple delimiters in PHP? ...
1
vote
1answer
25 views

regex birthday validation

I have a regex which validate birthday: if(!preg_match('/^(0?[1-9]|1[012])[- .\/](0?[1-9]|[12][0-9]|3[01])[- .\/](19|20)?[0-9]{2}$/', $_POST['bday']) { echo 'enter your birthdate in a valid ...
1
vote
2answers
19 views

get a string php regex match

here is my string 0 12 10 0 5 0 albert 126 al br t 881 alert 58 a lbr t 317 apart 251 al b rt 284 ambit 165 a lb rt 9 album 93 a l br t 881 10 6 13 0 einstein 92 en stein 219 epstein 8 e n stein 335 ...
1
vote
1answer
39 views

Regex does not work while parsing price

I am using regex to parse the currency in this format. I extract the price by scraping amazon.com $current_price=$doc['#current-price']->text(); $this->rawPrice=$current_price;//Value =$9.65 ...
0
votes
3answers
38 views

regex writes on “empty variable” & “not empty variable”

I'm quite exploring regex. All my regex are working using a trial and error. I'm very confused of writting for the empty variables. i have this regex: ...
-1
votes
2answers
55 views

Generic regular expression [on hold]

Ok, let's start again, more details now. I fetch my_meta['lieux']. At this moment, it looks like to string(176) "Paris:10/06/2013->link:20/09/2013->link ...
0
votes
1answer
26 views

Nasty regex and strange string behavior

I've been struggling with this problem for quite some time now and I just can't seem to find a solution. I have the following regular expression for matching URLs which appears to work flawlessly ...
-4
votes
1answer
22 views

Linkify text with also www.*** PHP [duplicate]

I was arguing with many regexp to find one supporting simply www.*.com url without the need to put http:// before. At present I'm using: $text= preg_replace("/(^|[\n ...
-1
votes
2answers
34 views

Regex to convert usernames within text to links to their profile [on hold]

Using this regex, I can find all usernames within the body of my comments and change them into hyperlinks: $body = preg_replace('/\B\@([a-zA-Z0-9_]{1,20})/', '<a ...
-1
votes
1answer
37 views

Regex match HTML tag and attributes [duplicate]

I'm trying to match html tag name along with it's attributes. In the example below, I am trying to match div, class, style and id. $html='<div class="nav" style="float:left;" id="navigation">'; ...
3
votes
4answers
40 views

Regex variable missing

I don't really know how they're called, the matches between brackets but variables seems legit. Anyway I have set up a custom ( or not so much ) markup to save links into my databases so that they'll ...
-1
votes
1answer
34 views

regex find and replace 'input tags'

I'm quite new to regular expression which I have trial and error test. How can I replace: <input name="token" type="text" id="test" value=""> like it will first search for the id="test" if ...
0
votes
1answer
24 views

PHP : Asking about the way preg_match works

I'm working on adding values into a template and have a problem. Here is my template TIME : |time,hour|:|time,min|:|time,sec| <br /> ADDING BLOCK 'TIME' ...<br /> ...
0
votes
1answer
16 views

Regular Expression Wordpress redirection plugin

I'm using the Redirection plugin to Wordpress, but can't get this regex to work. I'm not an expert on regex at all, so I guess I'm doing something wrong. /(.*)/(.*)/?rel=old /$1/$2/?rel=new When ...
1
vote
1answer
16 views

HTACCESS file to redirect all pages to maintenance.php but not if /admin is accesses

I have the following code which works perfectly for redirecting any page requested back to maintenance.php. However i would like the rule to ignore /admin as this is my admin panel that still needs to ...
0
votes
3answers
32 views

Regexp for validating simple pattern

I am trying to create regular expression that will validate simple patterns. Here a lists of valid and invalid patterns. Valid: foo, foo.bar, foo.bar.baz, *, *.foo, foo.*, *.foo.*, *.foo.bar, ...
0
votes
2answers
36 views

regex declare a 'default value' if a tag is empty

I have a regular expression which is it returns anything inside the html tag with id="test" ex: <span id="test">Hello World</span> <.*?id="pStyle".*?>(.*?)</.*?> it ...
0
votes
2answers
23 views

php regex preg_match on a variable containing a url

I'm trying to run a regex on a url to extract all the segments after the host. I can't get it working when the host segment is in a variable and i'm not sure how to get it working // this works ...
-1
votes
2answers
17 views

Having trouble with preg_match pinterest username url

Please help the statement i am using for matching pinterest username url is $url = http://pinterest.com/username preg_match("|^http(s)?://pinterest.com/(.*)?$|i", $url); but preg_match result are ...
0
votes
2answers
47 views

php select last 5 or 6 numbers with/without space

My data looks like: John 123 45 Doe 67890 Elly Clarkson 111 22 Chris Man Wu 44455 some92 thing91103 make1too 12120 make1too45100 How can I get last 5 or 6 digits with or without a space between? ...
1
vote
1answer
24 views

preg_replace every custom chars but URLs

hi i'm using WordPress and i want to replace the following $items = array( ".","?","!",",","؟","،",":","™","*" ); so i made up this function function Huemix_content_filter_chars($content){ $items ...
0
votes
1answer
45 views

What is the best way to parse text and code in my PHP blog?

Usually, I use nl2br() and it does come out just like it's entered in the textarea, but this causes a problem when using bbcode or posting code in <code> or <pre> tags, since it adds extra ...
2
votes
1answer
15 views

PHP Wordpress Shortcode Regex embedded in html

I am trying to parse out images from a wordpress post with get_the_content(). It returns a bunch of html and multiple lightbox shortcodes: <ul> <li>testing1</li> ...
1
vote
1answer
40 views

matching complete word using replace in php

I am using replace function in PHP to replace and underline word, $replace='<span style="font-weight:bold; border-bottom: 1px solid #999999;" >'.$term.'</span>'; $post = ...
0
votes
2answers
26 views

Regex attribute out of tag

I'm trying to regex src attribute (without its content/value) only and replace it with something else. It has to verify the HTML tag also (img in the example). Test data example: <img ...
0
votes
2answers
29 views

regex validation cyrillic domain

I need to write a regular expression to validate Latin and Cyrillic domain name. I wrote this function, but it does not work with Cyrillic domains. Tell me what's wrong? function isDomain($url) ...
2
votes
3answers
32 views

convert short youtube url to full url

Hi all i am looking for a simple way to check if a string equals an url like this: http://youtu.be/WWQZ046NeUA To convert it to a proper youtube url like this: ...
1
vote
1answer
27 views

Regex word boundary alternatives inside parentheses does not work?

There is something I could not understand with the word boundary. $input="157-XYZ"; preg_match("/[^\d+\-]\bRDS|xyz|ABC\b/i", $input, $output); The above preg_match matches XYZ in $input. However, ...
1
vote
1answer
39 views

Extract a string between two words

I want to extract hash from string below which is e5e1af55bad959546ec7608cc8685fe67bc5426e $word1 = 'btih:'; $word2 = '&dn'; $magnet = ...
1
vote
2answers
32 views

php regex for last number before file extension

Anyone know how to use preg_match to get last digit given this: images/listings/listings_id_15_4.pngor images/listings/listings_id_15_4.jpg The extension may be different, I only need to find the ...
3
votes
2answers
29 views

.htaccess multiple variable rewriting

I managed to put together .htaccess like this and it is working fine RewriteRule ^$ /splash [L,R=301] RewriteCond %{HTTP_HOST} ^example.com RewriteRule (.*) http://www.examle.com/$1 ...
1
vote
1answer
21 views

.htaccess RewriteRule performance (large amount of RegEx)

I am using the following .htaccess rules to rewrite multiple urls on my website: RewriteEngine On RewriteRule ^privacy(\w|\s|\+|-|&|;|#)+policy/?$ index.php?page=privacy [NC] RewriteRule ...
0
votes
1answer
24 views

PHP regex to parse wordpress shortcode attribute

I am trying to regex all lightbox wordpress shortcodes and receive their 'link' attribute. Example: [lightbox link="http://www.test.com/photo1.jpg" width="150" align="none" title="photo 1" ...
2
votes
6answers
49 views

Regex Match Replace

Im trying to figure out a regex pattern that will look through array below and replace any matching that has a '+' in it with emtpy/null, so if it has a positive number in it then make it null. ...
0
votes
1answer
48 views

How to determine if a string is a valid v4 UUID?

I'm making a validator based on UUID generated by client browser, i use this to identify a certain type data that the user sends; and would like to validate that the UUID that client sends it is in ...
3
votes
7answers
72 views

PHP Regex match between two patterns

I'm attempting to parse through a log file containing numerous traces, some of which have multiple lines to them. Example: [trace-123] <request>This is a log line</request> [trace-124] ...
0
votes
4answers
35 views

Search two words in string to verify that one word precedes the other word

After a lot of googling, asking question on here. I want to be able to search a string to verify that one word precedes the other (in php), but not necessarily adjacent to each other. I was so sure ...
0
votes
3answers
57 views

Regular Expression doesnt work in a right way

first of all, I dont have any knowledge in modifying regex.. I just got this code from some forum.. $urlregex = '~(?:http?)://[a-z0-9+$_-]+(?:\\.[a-z0-9+$_-]+)*' . ...
0
votes
5answers
33 views

Redirect all URL calls to a particular php file

Any http request (e.g. to pdf) should be redirected to validate.php so if you call an URL (e.g. http:...../whatever/whatever/1.pdf), htaccess should execute validate.php instead. I went through many ...
0
votes
3answers
32 views

regexp replace between some slashes

I need help with write regex pattern for replace my variable. Input data strings for parse: /hello/world/1111/2/3/4 /hello/world/2222/2/3/4 /hello/world/3333/2/3/4 /hello/world/3333 ...
0
votes
1answer
42 views

PHP Regex Match of Anchor Tag

I am trying to use REGEX to split a string apart while maintaining the delimeters. I wish to split a very large and unpredictable string apart via anchor tags. I am using HTML tidy to ensure the tags ...
3
votes
4answers
35 views

Preg_match exclude word from text

I have string: FirstWord word2 word3 wrongWord word4 lastWord Want to select string starts with FirstWord, ends with lastWord and doesn't contain wrongWord. For first and last I have: ...
1
vote
2answers
43 views

Understanding preg_match formula

I anyhow got my stuff working with following line, but I really could not understand. if (preg_match_all('/[^=]*=([^;@]*)/', shell_exec("/home/technoworld/Desktop/test/b '$test'"),$matches)) ...

15 30 50 per page