Tagged Questions
0
votes
0answers
30 views
PHP regex to parse a string of the form {string}\{string}
As per title I need to parse string of the form string_1\string_2 as in a string followed by a backslash then by another string with the following requirements:
if string_1 and string_2 are present, ...
1
vote
1answer
29 views
How to search urls that are not in any html tag and then turn them into hyperlinks?
So my problem is that, in the same content there are iframes, image tags and etc. They all have regex matches that will convert them into the correct format.
The last thing left is the normal URL. I ...
1
vote
1answer
20 views
Parsing unicode tweet text in PHP
I'm not sure which part of my script is actually wrong, but I'm having some hard time with parsing tweet text with unicode characters in it:
Example tweet:
Landsliðsmaður með viti. #rafhlaða ...
0
votes
0answers
18 views
Extract subdomain / domain from a text file using php
I've the following code which extracts domain name from the input and stores them in an array
foreach ($output as $domList)
{
$extensionList = explode(",", "org,com,net");
$pattern = ...
0
votes
6answers
35 views
preg_match - simple issue with trying to get sequence of digits
I'm trying to do a fairly simple extraction in PHP:
$empAward = 'AMW10';
if (preg_match("/\w+(\d+)/",$empAward,$matches)) {
$level = $matches[1]; // Wanted '10', but getting '0'
}
echo "Level is ...
-1
votes
1answer
27 views
Regular expression to replace mysql_fetch_array
Can someone make a regular expression for Notepad++ to replace this:
mysql_fetch_array($result)
by this:
$result->fetch_array()
The variable name could also have an other name, for example:
...
0
votes
2answers
29 views
Split PHP Variable in to array
A php variable contains
$string = "256 Engineering Maths-I 21 -1 21 F";
printing
$string
gives output
256 Engineering Maths-I 21 -1 21 F
this variable should split in to
$n[0] = "256";
...
1
vote
1answer
40 views
How do I make sure regular expression is matched both times?
I currently use the following regex (in PHP):
preg_match_all('/\s+?[-]{3,}\s(POST|GET|PUT|DELETE)\s([\/A-Za-z\-_{}]*)\s+(.*)\s+[-]{3,}\s+/ism',$text, $m, PREG_SET_ORDER)
Basically, it works fine, ...
1
vote
2answers
75 views
PHP, Invalid characters in JSON decode
I'm having troubles getting json_decode to work on a string I am collecting.
I have narrowed it down to this line:
"systemNotes[6]": "January 09, 2013 12:52 PM - Test Name - Changed Billing Address ...
3
votes
2answers
82 views
How can I replace single 's with a space but, not if there are multiple s?
I assume a regular expression might do the trick but I haven't been able to come up with one that works. I have some fairly long strings in PHP that I need to clean up. In some cases, ...
0
votes
1answer
20 views
Add a semicolon to the Codeigniter permitted URL chars
I need to add a semicolon (;) to the Codeigniter permitted URL chars pattern, here is the code:
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_-';
I need to add the semicolon (I need this because ...
0
votes
1answer
46 views
how to use preg_replace to replace all ocurrences of a given pattern?
I have a pattern (a slash followed by 1 or more dashes) inside strings that could occur many times like
/hi/--hello/-hi
I want to replace it with
/hi/hello/hi
I have tried
$str = ...
1
vote
1answer
40 views
Why does my regex do the matching as expect, but shows the rest of the content at the end?
So, I got this code:
function PCRT ($input) {
if (preg_match('/youtube\.com\/watch\?v=([^\&\?\/]+)/', $input, $id)) {
echo '1<pre>'; print_r($id); echo '</pre>';
} ...
-5
votes
1answer
31 views
TextBox Not Allow Certain Characters in Like (? and &) [on hold]
I want with preg_match catch a value with characters & or ?
Is that possible ?
Thank for your time
-1
votes
2answers
43 views
Regex not validating whitespaces [on hold]
Problem in regex. It is not validating spaces. Means if field is madatory, white spaces are considered as some input. beow is the regex validation i have applied.
<key ...