Skip to main content
Filter by
Sorted by
Tagged with
1 vote
3 answers
72 views

I have a website where users are required to write a simple, short profile description. Some users are writing ugly profiles with a bunch of empty spaces, and excess new lines. It's a lot of work to ...
peppy's user avatar
  • 197
-7 votes
1 answer
124 views

I want to replace the following hyperlinks dynamically from <a href="/xsearch2?q=some search/21">21</a> to <a href="/xsearch2?q=some search&page=21">21</a&...
KTH Clips's user avatar
-1 votes
1 answer
96 views

I want to highlight my search query on a formatted number. For example: $search_query = '1234'; // or $search_query = '7800'; $formatted_numeber = '12,345,678.00'; Currently my code is: preg_replace('...
Kazi Nahian's user avatar
0 votes
1 answer
72 views

I have this simple line of php $text = preg_replace("/\\ii(.*?)\\<>/", "<img scr='img/$1'>", $text); Where I change II30.jpgII to <img scr='img/30.jpg'>, and it ...
Jorgensen's user avatar
1 vote
0 answers
90 views

So I am currently using this regex, but I see a flaw in it for p and div tags: (<(p?|div?)>).+(\s|&nbsp;)+(<\/(p?|div?)>)+ Given the current string: <div class="blahblahblah ...
Solomon Closson C's user avatar
0 votes
0 answers
36 views

I'm in the process of upgrading my site's engine. The new version does not support bbcodes, and all my forum posts and articles are created using it. I want to make a script to convert all text with ...
Leks's user avatar
  • 1
4 votes
3 answers
148 views

In PHP I need to highlight multiple given words in a string, for example wrapping found matches inside a <em> tag. But if I have a word ending in + I cannot do it. I understand the below problem ...
adrianTNT's user avatar
  • 4,163
0 votes
0 answers
27 views

I have to determine all short tags like [field id="key1"] in the string, get the keys from the short tags to use them to get the values like $fields["key1"], then replace in the ...
user avatar
0 votes
1 answer
120 views

I need a php preg_replace to allow only the first occurence of ' and -, the rest will be removed and no numbers and other special characters. So Mike O' Hara's Du-Pont Check-In will become Mike O' ...
ruzip's user avatar
  • 63
0 votes
0 answers
73 views

As part of a migration, I wrote a function to transform links, prepending a path ("/my/files") to existing paths from the source site. Here is my function: function example_file_urls($text) ...
arnoldbird's user avatar
0 votes
1 answer
75 views

I've been using file_get_contents in php until the last month when it's stopped working. So I've tried using curl but I'm now getting errors when I extract data from the downloaded webpage (finance....
Chris Appleby's user avatar
0 votes
1 answer
66 views

Get a warning because the e modifier deprecation on preg_replace function. Here is the code, I suggest that should be replaced by preg_replace_callback function (for php 7.4.16) : `$text = ...
Rovsan's user avatar
  • 23
0 votes
2 answers
106 views

I'm trying to create a perl regular expression that matches a URL that is not preceded by an equal sign and one single or double quote (optional) ignoring whitespace. The code below gives an error: ...
developer981's user avatar
0 votes
2 answers
52 views

I have a span tag that has role attr button. What I want to achieve is to remove the whole span while matching not the span itself but the role attribute $str = 'This is a test buton. <span id=&...
lStoilov's user avatar
  • 1,351
-1 votes
1 answer
106 views

I'm looking for a preg_replace that can replace " with ' when between font-family: and ; I'm having an issue with my some dynamic html I'm using which requires me to replace the quotes with ...
Tyler Fontaine's user avatar
1 vote
1 answer
52 views

I was using str_replace to rewrite URLs to PDFs from https://example.com/documents/en/whatever.PDF to https://example.com/documents/es/whatever_SPANISH.pdf This is what I was using if($_COOKIE['...
Joshua Pettit's user avatar
0 votes
0 answers
46 views

I have a function highlighting word for a glossary. I created a regex to replace occurrence of word that are preceded and followed by word starting/ending characters like spaces, commas, HTML tags, ...
Alex Vio's user avatar
0 votes
0 answers
71 views

We receive HTML blood files for clients and I am trying to finish some PHP code to strip, clean and preg strip the code so that I can assemble multiple files into a spreadsheet. The issue is that the ...
nathanhunt79's user avatar
1 vote
2 answers
100 views

I have content that is coming dynamic but some characters from string are missing. I want to replace that characters to make it correct. I have complete order id but in content it's coming with space....
parv's user avatar
  • 117
0 votes
1 answer
47 views

I loaded a csv to array. And I want to put " to column 21 if they don't have yet. This is sample of column 21. Some are empty. It's $data[21] in my case. 21 14" 14" 14" empty 16&...
Pekzz's user avatar
  • 75
0 votes
2 answers
81 views

Given some urls inside an html page, I want to replace some urls as below: Example url: https://example.com/cost-center/sub-one/article1 From that one I want to replace the text that is between /cost-...
bledi's user avatar
  • 13
0 votes
2 answers
94 views

I am learning php language. I want to show the table of contents for the article. Convert the headings (h2,h3,h4,...) into a list and create links. This is my php code. $Post = ' <h2>Title 01<...
behroz's user avatar
  • 126
0 votes
2 answers
86 views

I am learning the language php. I have two functions and I want to connect these two and show them in one output php. <?php function link_follow($id) { $title = ''; $slug = ''; if ( $id ...
behroz's user avatar
  • 126
0 votes
1 answer
52 views

For example, I have two strings "abcdef" "abcdefghijk" I want to replace the first one, but not the second one which begins with the same string. However, the first one can be ...
ray61's user avatar
  • 11
0 votes
1 answer
88 views

I have a html string that contains many images.each image has some attribute like class ,id , style , .... I want remove all attribute from img except src and alt. before : <img title="How to&...
PCcloob.Ir's user avatar
-2 votes
1 answer
37 views

I have a string of "You can go to kitchen and get some food for your dinner" and i need to change with preg_replace words You, your, food case insensitive to <i>y</i>ou,<i>...
Valijon Rahimov's user avatar
0 votes
2 answers
105 views

I've already tried a couple of regex but cannot fix this one: I need an enter line before the hashtags start (so there is some space). Example: It's essential to keep your pup cool in the summer ...
Jamie's user avatar
  • 11k
1 vote
3 answers
411 views

I did searches and figured this would be an easy find. Though I haven't found anything related to exactly what I need and similar questions are from people from overseas that have different phone ...
I_hate_arrays42's user avatar
-1 votes
2 answers
34 views

I need to insert only a HTTP in a list of links (10,000) that doesn't have one, for exemple <a href="nunm-press.com"> From <a href="nunm-press.com" to <a href="...
Andy62's user avatar
  • 1
-1 votes
1 answer
29 views

I have a problem with converting the string: $str = "1. List of word synonyms 2) Glass plastic products 3. Other product"; into an array list: Array( [0] => List of word synonyms [1] ...
Krystian's user avatar
0 votes
2 answers
325 views

I want a way to show SQL query how it will look with anonymous parameters (?) substituted by actual parameters. This is only for readability purposes and debugging, and wouldn't be used as an actual ...
Mike's user avatar
  • 19
0 votes
1 answer
50 views

$pedit =<<<head <div class="item"><div var="i_name_10">white gold</div> <div var="i_price_10">$5.99</div></div> head; echo ...
kim li's user avatar
  • 21
1 vote
2 answers
54 views

$pedit =<<<head <div class="item"><div var="i_name_10">white gold</div> <div var="i_price_10">$5.99</div></div> head; $...
kim li's user avatar
  • 21
1 vote
1 answer
56 views

I have a string, and within it there will be combinations of [ ] [[ ]] ][ but I need to replace the single [ and ] with < and > but leave alone (don't match) anything that is between [[ ]]. I ...
Richard Taylor's user avatar
1 vote
1 answer
106 views

I would like to convert the coordinates displayed in Apple Maps as 38,89016° N, 1,22427° O (German notation) or 38.89016° N, 1.22427° E (English notation) into something like 38.89016, 1.22427 (...
Tim Nikischin's user avatar
1 vote
2 answers
37 views

I'm trying to use PHP to replace some item ids in a piece of JSON, and experiencing a problem where the replacements from the first pass are being overwritten by the replacements from the second pass. ...
JTW's user avatar
  • 53
1 vote
1 answer
77 views

Not sure how to proceed to allow or prevent snipping at underscore and colon in urls in this preg_replace. Also not sure what other special characters I might be missing that will snip the url $text = ...
Rubbish's user avatar
  • 31
0 votes
1 answer
65 views

In JSON string I need to replace inconsistent values in multiple instances String format to replace within each instance inconsistent value 252/2022/08 to be replaced with consistent value 178/2023/03 ...
Nadal's user avatar
  • 105
0 votes
1 answer
64 views

I want to perform value replacement based on matched value. The replacement expression has calculation based on matched value. regex <?php $re = '/<w:d([^\[]+)\/>/m'; $str = '<w:d2/>';...
Premlatha's user avatar
  • 2,004
-1 votes
2 answers
76 views

Regx is not my thing. I have a large file where I want to replace the following example: <g:id><![CDATA[131614-3XL]]></g:id> should be replace with: <g:id><![CDATA[131614-...
Ulrik Neerup's user avatar
-2 votes
2 answers
137 views

I have this tag on an HTML code: text html [button link="google.com" color="#fff" text="this text here"] rest of html I wish i could have the parameters of this "...
Luiz Jr's user avatar
  • 71
0 votes
1 answer
222 views

I am trying to create a side anchor navigation that will build out the side nav for every h2 tag header. I have the side nav portion working just the way I want it to. It pulls the h2 out of the ...
EdgarAlexPoe's user avatar
2 votes
2 answers
111 views

I want to replace all the string values from example.com to sample.com excluding the image extension .png, .jpeg, .jpg etc. $body = ' www.example.com, example.com, example.com/hello.html, example.com/...
Mehul Kumar's user avatar
2 votes
4 answers
275 views

I am using preg_replace or str_replace in PHP to replace all the domain name including www $string = ' https://example.com, https://www.example.com, https://subdomain.example.com '; $olddomain= "...
Mehul Kumar's user avatar
-2 votes
1 answer
54 views

$settings['new_primary_colour_ccs'] = '#777777'; // test color foreach($appPats as $path){ $styleSettings = [ 'primary_colour' => [ 'reg' => "\bprimaryColour:\s?['\&...
Alex Kizyma's user avatar
0 votes
1 answer
401 views

I am trying to remove from a string all characters that do not match to a list of words. my list of words could be: person animal a string can look like this: 123-ea-person.jpg 456456-on-Person.jpg ...
pino's user avatar
  • 164
2 votes
2 answers
64 views

I am trying to replace a dash between two time values and replace it with the word to but only if before the first time value there is the word from This is what I have until now, which works fine, ...
lStoilov's user avatar
  • 1,351
0 votes
1 answer
56 views

I have a function that converts numbers into words called NumberToWords. Then I have a sentence like this $str = "There are 3 cats and 5 dogs". NumberToWords(3) will read three NumberToWords(...
lStoilov's user avatar
  • 1,351
0 votes
0 answers
41 views

I'm building a website and I have created a couple of custom functions that add certain information on the page. One of them is as follows: {{i|Custom argument 1|Custom argument 2|Custom argument 3|......
OciXCrom's user avatar
1 vote
1 answer
61 views

I am creating a username from the users Billing First Name and Billing Last Name. This in in. WooCommerce, though I suppose the cms is irrelevant to my question. The following characters should be ...
Schalk Joubert's user avatar

1
2 3 4 5
117