Tagged Questions
0
votes
5answers
36 views
PHP Extract from the string
I am new to php and need to extract "url" from following string
href=\"https://www.youtube.com/watch?v=gYDSNteP_60\">Fat, me? I'm just horizontally challenged"
Url length is vary for different URL's
...
1
vote
1answer
14 views
Exclude multiple paths from htaccess rewrite rule
I created a new function with the hope of achieving breadcrumbs and a better URL structure.
Before this I had the following rule:
RewriteRule ^pages/([a-z0-9,&-]+)/?$ ...
0
votes
2answers
23 views
Fetch value from text file using preg_match PHP
I have a text file in following format.
Wed Aug 27 20:24:53.536 IST
address ref clock st when poll reach delay offset disp
*~172.16.18.163 .GPS. 1 657 1024 ...
0
votes
1answer
25 views
Needed Help About Regex
I have long struggled with programming languages such as PHP, Javascript, HTML, etc. But my weakness is still very disturbing is about regex.
Previously I felt comfortable without understanding it ...
-1
votes
1answer
26 views
Extract data form php/curl parsing
I have a html document to parse with curl.
This is the part where i'm trying to extract particular data :
<table align="center"><td class="normal" valign="top">
<b>Name ...
0
votes
0answers
19 views
preg_match depreciated usage resolution
I wrote this code almost 4 years ago and it ran fine up until I upgrade SQL/Apache last week.
Now I have an issue with my error checking, when a form is filled out correctly it still yields an error ...
0
votes
1answer
36 views
Trying to build a php excerpt function
I pull a bunch of content from a field on a database.
This content can be anything from the standard
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been ...
2
votes
3answers
21 views
Replace anything regex php
i have this regex in php
$array_item_aux = str_replace('/.*PUBMED=/',"",$array_item);
it shoul be replacing this text
...
0
votes
3answers
41 views
How to check if a string contains only letters in PHP? [duplicate]
I want to write a PHP code which checks whether a variable contains only letters NOT characters not numbers, I have typed this but it's not working:
$myVar = "Var#iable5";
ereg(^[a-zA-Z] , $myVar)
0
votes
3answers
52 views
PHP: Strip specific tags but leave content
I want to remove specific <font> tags from my html only if a class attribute doesn't exist. I've already tried using the below regex:
/<font(.*?)>(.*?)<\/font>/
along with ...
1
vote
2answers
31 views
PHP pcre regex to find content of curly brackets
I need PHP pcre regex to find content of all curly brackets...
Why is this regex doesn't work?
<?php
$str = "test{it}test{/it}test";
$ret = preg_match_all("#\{.?\}#u", $str, $matches);
...
0
votes
1answer
15 views
regexpneed to find word with minus and others
i have for now few types of code that i need to find and replace with regex.
{word1/G_KP8zXsDp8/word2}
{word1/GKP8zXsDp8/word2}
{word1/G-KP8zXsDp8/word2}
my replacement now is: ...
0
votes
1answer
60 views
mysql regexp in where clause
I have a mysql query
SELECT jss_products . * , jss_extrafields_values.content as test_weight
FROM jss_products_tree
INNER JOIN jss_products ON jss_products.productID = ...
0
votes
3answers
28 views
Regex not matching the pattern with spaces and new lines
I am trying to get from a string Passed, <strong class="has_warnings">2 warning(s)</strong>. I am a noob in regex please help.
$str_html = '
<td colspan="2" class="valid">
...
0
votes
2answers
36 views
Replace repeating charachters with only one character in php
I want to check if a string contains more than or equals 3 times a letter/number and replace it with only one letter/number. For example:
IIIII havvvvve a bigggg tesssssttttt tomorrow soooo iiii ...
0
votes
1answer
16 views
php Regular expression, containg x in mid start with - and every char is 3
Regular expression, containg x in mid start with -
I have more than 2000 url that contain pattren look like -120x150 in every url i want replace than with space in PHP
url
...
1
vote
2answers
35 views
get table data with curl and regex
this is my code to extract data from table.
but I want delete links.
and how pieces title and price to array.
<?php
$ch = curl_init ...
0
votes
6answers
45 views
regular expression to detect integers followed by some string format
I have the following check currently to match if a string is a not a number
if (!ctype_digit($matching)) {
}
however now I wanted to change this such that I wanted to detect the following format:
...
0
votes
1answer
59 views
How can I get rid of all JavaScript from an HTML page?
I could use regex to get rid of the <script> tags in the HTML like this
$html = preg_replace('#<script(.*?)>(.*?)</script>#is','', $html);
So that works fine, but what about ...
-1
votes
1answer
26 views
PHP : Execute a form validation with regular expression then submit
The script below works fine to validate inputs. the issues is after validation i want to send the data to another script so it can stored in the DB. How can i edit the action attribute to get what i ...
3
votes
3answers
38 views
RegEx to remove /** */ and // ** **// php comments
ReGex newbie here.
I need to remove two different style comments from PHP files using RegEx.
I've found this expression to run in the BBEdit text editor:
\/\*[\s\S]*?\*\/
and it removes comments ...
0
votes
1answer
27 views
How to use preg_replace regex for turning * into HTML
I have paragraphs of texts with this kind of markup in them:
text1 *text2* text3
I need to turn them into
text1 <strong>text2</strong> text3
I tried this code
$pattern = ...
-1
votes
2answers
36 views
php regular expression match number with 2 digitis only, no partial number
I have the following problem in php:
I want to extract a number that has two digits only and is not a partial of a longer number.
I'm using preg_match() and want to have the number only as the match ...
0
votes
4answers
51 views
Remove last characters of strings using regex
I need to find a way in PHP to remove the last portions of 2 strings using regex's. This way once they are stripped of the extra characters I can find a match between them. Here is an example of the ...
1
vote
4answers
24 views
Replace multiple characters with multiple replacers
I have many calls like this throughout the code, escaping any backticks on the columns of a row.
htmlentities(str_replace("`", "``", $row['column']), ENT_QUOTES);
I made an addition, requiring the ...
0
votes
2answers
28 views
PHP, regex issue with non Latin characters
In a string I'm trying to remove everything inside parentheses with preg_replace but I have some issue with non Latin characters.
I tried:
$text = '(Hàng Refurbished) sdfsdfsdfsd (Đen)';
$text = ...
-4
votes
2answers
23 views
Using preg_match_all to convert repeated data into array
Please help me to do following things,
I need to sort the string
this.message(data1,{data2}, {data3},data4); this.message(data5,{data6}, {data7},data8); this.message(data9,{data10}, ...
-4
votes
0answers
28 views
Correct RegEx expression in PHP [on hold]
Here is a stupid sentence.
In the USA but also in the (USA) or[USA] but not in usable but also find usa.
I can't for the life of me get my head around RegEx's. What I need is the expression that ...
-1
votes
0answers
25 views
Html (Time)Table to array in PHP
On my school we have a online time table for each class, mine is http://roosters.stc-r.nl/2014-2015%20Roosters/Rotterdam/p1/36/c/c00011.htm . Now I want to load HTML table into an array and export it ...
-3
votes
1answer
56 views
Only match URL beginning with 'www' or 'http(s)://' [on hold]
I have a regex pattern
/(href=")?([-a-zA-Z0-9@:%_\+.~#?&\/\/=]{2,256}\.[a-z]{2,4}\b(\/?[-a-zA-Z0-9@:%_\+.~#?&\/\/=]+)?)/
Which works great, it matches all URLs, but if I type something ...
-1
votes
0answers
19 views
Regex to remove javascript top.location.href redirect
I have this regex:
<script[^>]*?>[a-zA-Z0-9]*?[\D]+?\S+?\s+?top\.location\.href.*?\r*?\s*?<\/script>
It is working for something like the following:
<SCRIPT ...
0
votes
0answers
17 views
preg_replace to remove img and iframe? [duplicate]
i need some help.
I have this code to remove iframe from my content (conteudo). OK.
//Remove Iframe //
$str = $row_ultimos_posts['conteudo'];
//result
echo ...
1
vote
4answers
56 views
Explode and/or regex text to HTML link in PHP
I have a database of texts that contains this kind of syntax in the middle of English sentences that I need to turn into HTML links using PHP
"text1(text1)":http://www.example.com/mypage
Notes:
...
0
votes
2answers
33 views
PHP - Auto-filling/generating with regex validation
I have the following (ugly and just for tests) code:
$numeros = range(0,9);
$letras = range('A', 'Z');
$contador = 0;
$maximo = 10;
$input='';
$pattern = ...
1
vote
2answers
33 views
Extract css from html
I'm looking for a clean way to grab and remove all the css between the <style></style> tags.
For example:
<style>
foo
</style>
content
<style>
bar
</style>
here
...
1
vote
3answers
57 views
How to match something like AOrBOrCOrDOrE
I have a sentence like this: "AOrbOrCOrDOreOrdOr..." . I'm trying to match all the word like "A", "b", "C" and so on. But, it just returns "A", "bOr", "cOr",... Here is my pattern: ...
0
votes
1answer
50 views
Allow single ,double quote and full stop with Regex
I have implement validation with cake php model only letters allowed. below is code
'referer' => array(
'notempty3' => array(
'rule' => '/^[a-zA-Z\s]+$/',
'message' ...
1
vote
1answer
36 views
Javascript and PHP Regular Expressions to Capture Email Address found in related recipient fields
I'm trying to develop 2 regular expressions, one in javascript and the other in php, that will capture the email address(es), found in a raw email message, that only pertain to it's respective field ...
-2
votes
2answers
35 views
PHP addslashes to predefined set of characters
How can I prepend certain characters with a backslash in a single function?
The equivalent of doing a bunch of str_replaces:
$text = "asdf[],.\?'";
$text = str_replace("'","\'", $text);
$text = ...
0
votes
2answers
39 views
extracting from array in php
i am learning php trying to understand below array,
i need to grab content-type, it should give me
text/xml;charset=UTF-8 and then
i have to grab encoding
from it which is UTF-8
any one good ...
-3
votes
1answer
29 views
route must match Symfony2
I'm very bad with regular expressions and I have a problem with my Symfony2 routes
This is my yml route
ilppa_adverse_view:
path: /{adverseReference}/{adverseName}
defaults:
...
1
vote
3answers
24 views
How can I ensure what I'm about to str_ireplace isn't a part of a url?
I've got the following code;
$array = ["example","exam ple"];
$message = str_ireplace($array, 'ExamPle', $message);
I'm trying to replace mentions of my website's name with the cute stylised ...
0
votes
0answers
40 views
Parsing nested function body PHP
i am trying to get this working: It is ment to return any function or method where the different 'functional parts' are subgrouped. I have problems with the maybe nested {..{.{} } } function body. At ...
0
votes
1answer
20 views
Wordpress seems to replace all underscores with dashes since 9.1.2 in uploaded files. How can I remove this?
I have noticed that it seems like that Wordpress is replacing all underscores with dashes in uploaded file names since the lastest update (9.1.2). However, I need the underscores in the file names to ...
0
votes
3answers
51 views
Using Regex to search for a word before a given word
I am slowly piecing together an implementation of class.iCalReader.php, to take an iCal feed and produce a table with all the events that are going on in a building on a particular day. As part of ...
1
vote
1answer
29 views
Replacing URL pattern for MySQL
I'm trying to figure out how to use a regex search on a MySQL column to update some data.
The problem is I'm trying to rename part of a URL (i.e a directory).
The table looks something like this ...
0
votes
1answer
36 views
match if url is starting with certain characters
I am developing a project in codeigniter, I don't have much knowledge of regular expression. I want to check a url in codeigniter route.
This is my url example
single-user-abc-name-1540
The ...
-2
votes
1answer
18 views
xpath query with regex on node which contains some text
I want to get nodes which contain this text "$$$EXM_TAB$$$"
$exampleNodes = $XPath->query('//*[contains(text(),"$$$EXM_TAB$$$")]');
foreach($exampleNodes as $exampleNode){
...
1
vote
2answers
26 views
PHP preg_replace
I'm stuck with this one...
I insert some data into a database table which comes from a form. Sometimes, this data contains html, so I do
$note = ...
0
votes
0answers
30 views
PHP preg_replace causing preg_last_error()
Not being great at regex I am trying to fix some code which errors on several preg_replace functions eg
$string = ...