str-replace

dplyr string match and replace based on lookup table in R

和自甴很熟 提交于 2020-01-16 18:27:28
问题 I'm trying to achieve a function that I previously did in Excel, but having trouble finding a means to achieve it. I have two datasets: one is my base dataset and the other is a lookup table. My base has two columns, the first and last names of people. My lookup table has these first two columns as well, but it also includes a replacement first name. People <- data.frame( Fname = c("Tom","Tom","Jerry","Ben","Rod","John","Perry","Rod"), Sname = c("Harper","Kingston","Ribery","Ghazali","Baker",

R str_replace_all except periods and dashes

荒凉一梦 提交于 2020-01-15 10:05:03
问题 I am trying to replace all punctuation and "not words" except for "." and "-" in a string, but am struggling to find the right combination to set up the regex expression. I've been using the following str_replace_all() code in R, but now I want to specify to ignore "." and "-". I've tried setting it up to include things like [^.-] and ([.-]), but I'm not getting the desired output. str_replace_all("[APPLE/O.ORANGE*PLUM-11]", regex("[\\W+,[:punct:]]", perl=T)," ") " APPLE O ORANGE PLUM 11 "

Need to replace 13 blank spaces from 1 very long line of text file

混江龙づ霸主 提交于 2020-01-15 07:55:20
问题 I have a file (1.8 Mb) that has 1 single (very long) row of text. The values on that row are generally separated by 13 blank spaces. What I am trying to do is to replace these 13 blank spaces with a pipe | delimiter so that I can process this text file using SSIS. So far, I have had no success in programmatically processing this file using a batch file. I have tried using the below code that I got from another SO post. @echo off REM create empty file: break>R1.txt setlocal

str_replace keys in multidimensional array PHP

有些话、适合烂在心里 提交于 2020-01-15 03:35:09
问题 I have a multidimensional array like the following: Array ( [results] => Array ( [0] => Array ( [object_id] => 13 [id] => 13 [idno] => e00110-o00005-2010-PROG [display_label] => La Bohème / PUCCINI - 2010 [ca_objects.description] => Libreto de Luigi Illica y Giuseppe Giacosa basado en Escenas de la vida bohemia de Henri Murger Nueva producción – Teatro Colón [ca_objects.type_id] => Programa de mano ) //more data here I'm trying to loop the array and replace "object_id" key for "new_id" using

My code with str_replace don't work

前提是你 提交于 2020-01-11 11:56:07
问题 why this code isn't working? I was trying to rename, switch location and other, but it seems to be str_replace bug. It would be nice, if somebody told me, what's wrong... This is my index.php <?php header('Content-Type:text/html;charset=utf-8'); session_start(); require_once ('inc/core.php'); $core = new core($_GET['viev']); this is core.php <?php class core{ var $template; var $view; public function __construct($view) { $this->template = $this->loadTemplate(); $this->view = $view; $this-

PHP Simple way to replace or remove empty lines with str_replace

天大地大妈咪最大 提交于 2020-01-11 06:17:10
问题 $line-out = str_replace('\r', '', str_replace('\n', '', $line-in)); The above works for me but, I saw a [\n\r] example somewhere and I cannot seem to find it. I just want to get rid any blank lines. The above is in a foreach loop. Thanks for teaching. 回答1: You shouldn't use - in variable names ;) $line_out = preg_replace('/[\n\r]+/', '', $line_in); $line_out = str_replace(array("\n", "\r"), '', $line_in); Manual entries: http://php.net/manual/en/function.preg-replace.php http://php.net/manual

Using str_replace multiple times on the same string

安稳与你 提交于 2020-01-10 02:38:25
问题 I'm looping through a title from a table so it's essentially something along these lines. foreach($c as $row){ echo string_shorten($row['title']); } What I'm doing is trying is a switch statement that would switch between what I want it to search for and once it's found replace it with what I choose in the str_replace: function string_shorten($text){ switch(strpos($text, $pos) !== false){ case "Hi": return str_replace('Hi','Hello', $text); break; } } Any suggestions or possible alternatives

exclude html attributes in str_replace

ぃ、小莉子 提交于 2020-01-07 05:51:07
问题 so i'm trying to do the usual replacing each instance of a company name in wordpress, and i've run into an issue where on occasion (usually in the href of links) it's breaking links. code i'm using (includes a filter for ACF custom fields) //Replace the word lunch with a span function replace_text_wps($text){ $replace = array( // 'WORD TO REPLACE' => 'REPLACE WORD WITH THIS' 'lunch!' => '<span class="lunch">lunch!</span>', 'Lunch!' => '<span class="lunch">lunch!</span>', 'LUNCH!' => '<span

Query multiple taxonomies group slugs

你说的曾经没有我的故事 提交于 2020-01-06 18:10:55
问题 I have a checkbox function that I'm using for my search query. My problem is the url created when I search. ?ct_zipcode=&ct_event_type=birthday&ct_event_type=photovideo-shoot&Venue-search=true When I have multiple taxonomy_names checked I only get the last slug in my search results. I need my url to be rewritten like: ?ct_zipcode=&ct_event_type=birthday%2Cphotovideo-shoot&Venue-search=true Is there an easy way to change my url with rewrite? I've tried a little str_replace / preg_replace with

Query multiple taxonomies group slugs

无人久伴 提交于 2020-01-06 18:10:29
问题 I have a checkbox function that I'm using for my search query. My problem is the url created when I search. ?ct_zipcode=&ct_event_type=birthday&ct_event_type=photovideo-shoot&Venue-search=true When I have multiple taxonomy_names checked I only get the last slug in my search results. I need my url to be rewritten like: ?ct_zipcode=&ct_event_type=birthday%2Cphotovideo-shoot&Venue-search=true Is there an easy way to change my url with rewrite? I've tried a little str_replace / preg_replace with