str-replace

Replacing \r\n (newline characters) after running json_encode

旧时模样 提交于 2019-12-06 22:21:23
问题 So when I run json_encode, it grabs the \r\n from MySQL aswell. I have tried rewriting strings in the database to no avail. I have tried changing the encoding in MySQL from the default latin1_swedish_ci to ascii_bin and utf8_bin. I have done tons of str_replace and chr(10), chr(13) stuff. I don't know what else to say or do so I'm gonna just leave this here.... $json = json_encode($new); if(isset($_GET['pretty'])) { echo str_replace("\/", "/", jsonReadable(parse($json))); } else { $json = str

How to remove non text chars from string PHP

做~自己de王妃 提交于 2019-12-06 16:23:35
How can I replace chars like 🎧🎬 from a string? Sometime the YouTube video title contains characters like this. I don't want to replace characters like !@#$%^&*(). I am currently using preg_replace('/[^A-Za-z0-9\-]/', '', $VideoTitle); Samples Array: $VideoTitles[]='Sia 2017 Cheap Thrills 2017 live 🎧🎬'; $VideoTitles[]='TAYLOR SWIFT - SHAKE IT OFF 🎬🎧 #1989'; Expected Output: Sia 2017 Cheap Thrills 2017 live TAYLOR SWIFT - SHAKE IT OFF #1989 Code with sample input: Demo $VideoTitles=[ 'Kilian à Dijon #4 • Vlog #2 • Primark again !? 🎬 - YouTube', 'Funfesty 🎧 🎬 on Twitter: "Je commence à avoir mal

PHP to SEARCH the Upper+Lower Case mixed Words in the strings?

不羁岁月 提交于 2019-12-06 14:25:35
Lets say there is a string like: A quick brOwn FOX called F. 4lviN The WORDS i want TO SEARCH must have the following conditions: The words containing MIXED Upper & Lower Cases Containing ONLY alphabets A to Z (A-Z a-z) (e.g: No numbers, NO commas, NO full-stops, NO dash .. etc) So suppose, when i search (for e.g in this string), the search result will be: brOwn Because it is the only word which contains both of Upper & Lower Case letters inside (and also containing only alphabets). So how can I make it work in php? You should be good with: preg_match_all("/\b([a-z]+[A-Z]+[a-zA-Z]*|[A-Z]+[a-z]

Javascript regex replace single slash in to double slash?

◇◆丶佛笑我妖孽 提交于 2019-12-06 11:50:01
Javascript regex replace single slash into double slash not for replace double slash in a string? var tempPath ="//DocumentImages//Invoices//USD//20130425//I27566554 Page- 1.tif&//hercimg/IMAGES/2008/20130411/16192144/16192144-10003.tif&"; Here replace all single slash in to double (//) not to all double slash. like //DocumentImages//Invoices//USD//20130425//I27566554 Page- 1.tif&//hercimg//IMAGES//2008//20130411//16192144//16192144-10003.tif& yourString.replace(/([^\/])\/([^\/])/g,"$1//$2") This would work assuming your string does not also end in a / yourString.replace(/\/[^\/]/g,"//")

PHP str_replace to replace need with random replacement from array?

百般思念 提交于 2019-12-06 09:36:55
问题 I've researched and need to find the best way to replace a need with an array of possibilities randomly. ie: $text = "Welcome to [city]. I want [city] to be a random version each time. [city] should not be the same [city] each time."; $keyword = "[city]"; $values = array("Orlando", "Dallas", "Atlanta", "Detroit", "Tampa", "Miami"); $result = str_replace("[$keyword]", $values, $text); The result is every occurrence has "Array" for city. I need to replace all of the city occurrences with a

Regular expression to remove an iframe

冷暖自知 提交于 2019-12-05 23:19:57
I'm trying to use str_replace to replace all iframes with my own content. I believe I can use regular expression but not exactly sure how to remove all content within the iframe tag. Since I'm not really sure how to achieve this, below is what I have been using. But it's only replacing "iframe" with nothing so when a page is loaded anywhere an iframe would load now just shows the URL that would have been loaded if the iframe were to parse properly. $toremove = str_replace("iframe", "", $toremove); Here is an example output of what gets loaded instead of the iframe when using the code above.

C++ replace multiple strings in a string in a single pass

淺唱寂寞╮ 提交于 2019-12-05 10:44:26
问题 Given the following string, "Hi ~+ and ^*. Is ^* still flying around ~+?" I want to replace all occurrences of "~+" and "^*" with "Bobby" and "Danny", so the string becomes: "Hi Bobby and Danny. Is Danny still flying around Bobby?" I would prefer not to have to call Boost replace function twice to replace the occurrences of the two different values. 回答1: I managed to implement the required replacement function using Boost.Iostreams. Specifically, the method I used was a filtering stream using

Replace multiple characters in a string variable (VBA)

雨燕双飞 提交于 2019-12-05 10:26:31
How can I replace more than one thing in a string variable? Here my example function in vba: Private Function ExampleFunc(ByVal unitNr$) As String If InStr(unitNr, "OE") > 0 Then unitNr = Replace(unitNr, "OE", "") unitNr = Replace(unitNr, ";", "") End If ... End Function Is there a better solution? You could use an array and loop over its elements: Sub MAIN() Dim s As String s = "123456qwerty" junk = Array("q", "w", "e", "r", "t", "y") For Each a In junk s = Replace(s, a, "") Next a MsgBox s End Sub Each element of junk can be either a sub-string or a single character. Does it need to be VBA?

php str_replace replacing itself

拟墨画扇 提交于 2019-12-05 08:30:17
I need to replace every occurrence of one of the letters a , o , i , e , u with [aoieu]? I tried to do the following: str_replace(array('a', 'o', 'i', 'e', 'u'), '[aoieu]?', $input); But when giving it input of black instead of giving me the expected bl[aoieu]?ck it gave me bl[a[ao[aoi[aoie[aoieu]?]?[aoieu]?]?[aoie[aoieu]?]?[aoieu]?]?[aoi[aoie[aoieu]?]?[aoieu]?]?[aoie[aoieu]?]?[aoieu]?]?ck How can I get it to not replace things it already replaced? You can consider using a regular expression for this, or you can make your own function which steps through the string one letter at a time. Here's

Replacing \\r\\n (newline characters) after running json_encode

邮差的信 提交于 2019-12-05 01:27:36
So when I run json_encode, it grabs the \r\n from MySQL aswell. I have tried rewriting strings in the database to no avail. I have tried changing the encoding in MySQL from the default latin1_swedish_ci to ascii_bin and utf8_bin. I have done tons of str_replace and chr(10), chr(13) stuff. I don't know what else to say or do so I'm gonna just leave this here.... $json = json_encode($new); if(isset($_GET['pretty'])) { echo str_replace("\/", "/", jsonReadable(parse($json))); } else { $json = str_replace("\/", "/", $json); echo parse($json); } The jsonReadable function is from here and the parse