FAQ Database Discussion Community


JS RegEx challenge: replacing recurring patterns of commas and numbers

javascript,regex,replace
I am fiddling with a program to convert Japanese addresses into romaji (latin alphabet) for use in an emergency broadcast system for foreigners living in a Japanese city. Emergency evacuation warnings are sent out to lists of areas all at once. I would like to be able to copy/paste this...

Regular expression to remove everything but words. java

java,regex,string,replace
This code doesn't seem doing the right job. It removes the spaces between the words! input = scan.nextLine().replaceAll("[^A-Za-z0-9]", ""); I want to remove all extra spaces and all numbers or abbreviations from a string, except words and this character: '. For Example: input: 34 [email protected] one 233 r # o'clock...

JS: Adding a space between Japanese character phrase and number using regex

javascript,regex,replace
I need to add a space between all instances of the Japanese 丁目(chome) that are directly followed a number of unspecified digit length. ex: 北23条東12丁目5-30-405 I have tried this (where s = "北23条東12丁目5-30-405") s.replace(/(?:丁目)+\d+/g, "$1 ") Since I want to add a space after a non-captured group, I thought a...

Replace values in column of a dataframe based on overlap with a vector

r,for-loop,replace
Good evening, I have a large dataframe of 150.000 lines and 7 columns as follows ID cola colb colc cold cole colf XXXYYY 0 0 0 0 0 0 XXYYXX 0 0 0 0 0 0 XYXYXY 0 0 0 0 0 0 YYYXXX 0 0 0 0 0 0...

Return value based on duplicate columns

mysql,sql,replace,duplicates
Table: firstname | lastname | age Joey | Sanchez | 33 Joey | Sanchez | 33 Rachel | Dudok | 28 I'm trying to make a MySQL select statement that returns a value "ERROR" in the age column when 2 columns are duplicates I tried the Case statement but it...

shell script for counting replacements

bash,replace,count
Ten files located in a directory. Each file content has "apple" word. write a bash shell script to replace "apple" with "banana" in all ten files and Print the number of replacements for each file. Have tried in this way but dont know how to get number of replacement. can...

Substitute string in BASH with Sed (when it has special characters)

bash,replace,sed
It's a fairly simple question and I'm sure the gurus here can figure it out right away, however I don't seem to be able to make it work (probably some quotes issue. I want to place all instances of: `which cat` With the following: /bin/cat I am running the following...

Swift - how to convert hyphen/minus sign into + sign

string,swift,replace,converter
I am obtaining address in string variable from iOS reverse geocoding from below code. CLGeocoder().reverseGeocodeLocation(imageLocation, completionHandler: {(placemarks, error) in dispatch_async(dispatch_get_main_queue(), { if (error != nil) {println("reverse geodcode fail: \(error.localizedDescription)") textField.placeholder = "Address not found." } else { if placemarks.count > 0 { var placemark:CLPlacemark = placemarks[0] as! CLPlacemark var...

Using regex to extract multiple strings

regex,xml,string,replace
I've looked at quite a few different posts relating to this but I'm still running into a few problems. I need to remove the value between multiple specific tags, without touching others with a similar name. For example, remove value for "LastName" but not for "Last". Here is my sample...

How do I replace certain PHP values with my own text?

php,arrays,string,wordpress,replace
Here is my PHP code: $order_data = array( 'shipping_method' => $order->get_shippingmethod(), ); The 'shipping_method' value is currently exporting the following three values: 'Free Shipping' 'FedEx_GROUND' 'UPS Next Day Air' I'd like to replace this text with my own of my choosing. What do I have to add to the code...

Looping Over a String Gives Segmentation Fault

c++,string,replace,lowercase
I'm writing a function to make a string lowercase in C++. It works perfectly fine, but after the last character, it gives a segmentation fault. My code is below: #include <cctype> #include <string> #include <iostream> using namespace std; string lowercase(string str) { string ans = str; for (int i=0; i...

Replace backslash in string

java,regex,string,exception,replace
I have a String in which I am trying to replace the number enclosed by two backslashes. For example: \10\ , I am trying to replace that with 10. I am currently using this regex to do that: String texter = texthb.replaceAll("\\.+\\", "\\"+String.valueOf(pertotal + initper)+"\\"); This line is giving the...

How can I fix the following sed command?

regex,linux,unix,replace,sed
I am trying to append _out to anything that matches the regex shown in the follwing sed command. The _out should be before the [ (]. sed -n '/[^_]lm[01?]_.*[ (]/p' The command returns the lines correctly as I expect. Now the problem comes when I try the following command where...

Powershell variable in replacement string with named groups

regex,powershell,replace
The following Powershell replace operation with named groups s1 and s2 in regex (just for illustration, not a correct syntax) works fine : $s -Replace "(?<s1>....)(?<s2>...)" '${s2}xxx${s1}' My question is : how to replace with a variable $x instead of the literal xxx, that is, something like : $s -Replace...

Search for string in file while ignoring id and replacing only a substring

python,regex,string,replace
I’ve got a master .xml file generated by an external application and want to create several new .xmls by adapting and deleting some rows with python. The search strings and replace strings for these adaptions are stored within an array, e.g.: replaceArray = [ [u'ref_layerid_mapping="x4049" lyvis="off" toc_visible="off"', u'ref_layerid_mapping="x4049" lyvis="on" toc_visible="on"'],...

How to replace href inside of
  • using jQuery
  • jquery,replace,html-lists,href
    I am trying to convert a piece of code that is coming out out of a content holder. I need to modify the href within the <LI> tag using jQuery. Currently the code looks like this: <li id="ctl01_Auxiliary_Auxiliary_rptWrapper_Auxiliary_rptWrapper_rpt_ctl01_NavigationListItem" class="NavigationListItem"> <a id="ctl01_Auxiliary_Auxiliary_rptWrapper_Auxiliary_rptWrapper_rpt_ctl01_NavigationLink" class="NavigationLink" href="/Public/Cart/Core/cart/MyCart.aspx?hkey=70255604-fa6d-48b6-874e-ddb636d4f3ed"> <span...

    What is a regular expression for inserting a string into a Find and Replace match?

    c#,regex,replace
    I need a regular expression to replace all instances of: Session["ANYWORD"] == with Session["ANYWORD"].ToString() == I have Session\["\w+"]\s==, which correctly finds the right matches, but I don't know how to insert .ToString() into the match. What, or perhaps more appropriately, is there a regular expression to do what I need...

    How to do replace multiple times ? php

    php,string,replace,str-replace,php-5.3
    I want to replace word1 with word2 and word2 with word1 for this string : word1 word2 here is what i want to do : 1.replace word1 with word2 => I get : word2 word2 2.replace word2 with word1 => I should get word2 word1 . but I get this...

    Replace All Words In Document Body Doesn't Work

    javascript,replace
    Firstly sorry for my english, i have code that doesnt work when I execute it on <script language="javascript" src="/thecode.js"></script> I put thecode.js on footer var msg=document.body.innerHTML; for(var i=0;i<msg.length;i++){ var tx=document.body[i].innerHTML; tx=tx.replace(/dog/ig,'animal'); tx=tx.replace(/apple/ig,'fruit'); tx=tx.replace(/\[VIdEo\]/ig,'Video'); tx=tx.replace(/http\:\/\/example\.com/ig,'http://thelink.com'); document.body.innerHTML=tx;} I think i dont make any fault, but when i execute it, its doesnt work....

    Completely replacing a project with another person's project using Git

    git,replace,pull
    Me and another person are working on the same C# solution in VS, and we've run into some issues with a project called PL (using the Pull feature on git only gives me a ton of issues and conflicts that I've tried to take care of with no results). How...

    How to replace newlines/linebreaks with a single space, but only if they are inside of start/end regexes?

    regex,linux,shell,unix,replace
    I have an extremely big (many GBs in size) file that looks like [x data1 data2 data3 data4 y] [a data5 data 6 data7 data 8 b> [x data y] ...and so on How to replace newlines (which might be surrounded by spaces) with a single space, but only if...

    Strategy for Processing a Text File with a Header using Reg Exp in Java

    java,regex,replace
    I have a file that contains a header with comments (e.g. [Comment] This is a comment) and a subsequent data section. The data starts at "Mk1=". The program I am working on should: Copy the header contents Search and replace only in the data section of the file Write header...

    Replace special qoutes with normal

    vb.net,replace,utf-8
    In VB.NET how do I replace special opening and closing double quotes (“ and ”) with ASCII quotes ("). Ive tried s = s.replace("“", """") but it seems that Visual Studio consider the “ quote in my code to be a normal quote leaving me with an invalid statement....

    Microsoft Word 2010 VBA: Using regex to find and replace

    regex,replace,ms-word,word-vba,pci
    I'm trying to allow our staff to quickly mask the middle 8 digits of credit card data in old documents. I figure a macro using regex to do a find and replace is the fastest way for them. Masking is a PCI DSS requirement, and there may be hundreds or...

    Replace every occurence of [b: “text”] to text where text can be anything

    javascript,regex,replace
    I want to replace every occurence of [b: "text"] to <b>text</b> using JavaScript and RegEx. Currently I know how to replace [b: ""] to <b></b> using '/\[b: ""\]/g' but I can't figure out what to do if there is text between " symbols (it must be placed between html tags).

    Javascript Replace function not working on first instance

    javascript,jquery,string,if-statement,replace
    I am currently trying to make a list, using javascript and jquery that returns a string of keywords as shown here: keyword+keyword+keyword+keyword I am attempting to do this by adding a class 'active' when a keyword is clicked as shown in the code below, then checking whether it is active,...

    Sphinxql Replace() function like mysql

    replace,sphinx,sphinxql
    i can able to find search on mysql such as example below; Record is : I'Histoire Query search :IHistoire with this sql query i can able find word with ' string. select kitap_id,kitap_Adi,turu,fiyati,kargo,satici,yazari,yayinevi,yayin_Yili,yayin_Yeri,kucuk_Re sim,kondisyon FROM kitaplar WHERE onay='1' and (REPLACE(kitap_Adi,'''','' ) like '%IHistoire%' OR yazari like '%IHistoire%') order by fiyati...

    Replace characters in java string [duplicate]

    java,replace
    This question already has an answer here: Java Replace Regex not working 1 answer I am trying to replace the following text in some HTML: [merchant] I tried to use myString = myString.replace("\\[merchant\\]", "newText"); The string is not being replaced. Any ideas?...

    How define regex to delete all between two characters

    php,html,regex,string,replace
    I have problem with definition of regex pattern. In code below I want to delete all <p> tags and all attributes between <p > like style="bla bla", but I want keep other elements and their attributes like <img> in this case. I tried this pattern /\<p.*?\>|\s*/ but it's not working...

    how to convert (replace) a symbol to a html tag [closed]

    javascript,php,jquery,regex,replace
    In php I want to convert(replace) this string: $str= 'test1 **test2** test3'; to below string: $str= 'test1 <strong>test2</strong> test3'; In jquery (or js) this: var str='test1 **test2** test3' to: var str='test1 <strong>test2</strong> test3' ...

    how to replace NumberInt(1) to 1 with vim?

    regex,vim,replace
    I want to replace NumberInt(1) to 1 except in the string in my file with some tool: "bz":NumberInt(1), "batch": NumberInt(2), "something": "something else NumberInt(1)" "bz":NumberInt(1), "batch": NumberInt(2), "something": "something else NumberInt(2)" "bz":NumberInt(1), "batch": NumberInt(2), "something": "something else NumberInt(3)" "bz":NumberInt(1), "batch": NumberInt(2), "something": "something else NumberInt(4)" "bz":NumberInt(1), "batch": NumberInt(2), "something": "something...

    String replace with integer not working [closed]

    java,string,replace,integer,replaceall
    I have been working on some Java code and I came across a really weird error, Im trying to replace a piece of string with an Integer. Added all kinds of debugs but I cant seem to find it out. private void executeMsg() { value = value.replaceAll("(&([a-f0-9]))", "§$2"); String border...

    Batch-Script: Replace every [email protected] in file name with “_” in network drive including subfolders

    batch-file,replace,folder,filenames
    My Problem is this: I want to replace every Special character such as "@" in file names. Example: old file: [email protected] new file: test_home.txt This should be done in a special chosen Folder including subfolders. The user should easily Change the Location (Folder). Thx guys Alright Well, I will give...

    find common string in two text files using batch script

    string,parsing,batch-file,search,replace
    I'm trying to find common string in two text files. For example, first text file contains following 1.txt //documents #5 ##text //documents/A #6 //documents/B #7 second text file contains following: 2.txt //documents/A #3 output.txt //documents/A #6 If common string found, expected output last number taken from 1.txt file. try.cmd @echo...

    Assigning values from submatrices to larger matrix

    r,matrix,replace,assign,submatrix
    I have a bunch of small matrices, which are basically subsets of a larger matrix, but have different values. I want to take the values from these submatrices and overwrite the corresponding values in the larger matrix. For instance, say this is my larger matrix: AB-2000 AB-2600 AB-3500 AC-0100 AD-0100...

    Replace string :"{ using regex

    .net,regex,replace
    I have following string. str= ""10":"{\"read\":\"1\",\"write\":\"0\"}""; Now I want to replace string with :"{ to :{ and }" to } in above string using regex expression. Can anyone guide me to replace the character using regex or can use only replace method....

    Powershell For Loop, Replace, Split, Regex Matches

    regex,powershell,replace,split
    $i=0;$pnp = pnputil -e; $matched = [regex]::matches($pnp, ".......................................Lexmark International"); $split = $matched -split (".........inf"); $replace = $split -replace " Driver package provider : Lexmark International",""; $replace1 = $replace -replace " ","`n";write-output $replace1; foreach ($i in $replace1){;$pnpdel = pnputil -f -d $i;$pnpdel;}; Reg delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Environments\Windows x64\Drivers\Version-3\Lexmark Universal v2 XL" /f; net...

    LabVIEW variables Find and Replace

    variables,replace,labview
    How do I make all variables bound to numeric control a point to numeric control b instead? Original question I have a two Queue Refnums: old_queue and new_queue. I have a two Queue Refnums: old_queue and new_queue. How do I rebind all local variables bound to old_queue to new_queue?...

    Detect decimal number and alphabet in string

    c#,string,replace
    I am writing a mathematical application. How can I detect a number and alphabet in string in c#. For Example: string a = "2x"; // input string string b = a.Replace("2x","2*x"); // Replace string to add multiplaction sign between a number and variable It could be an integer or double...

    Replacing elements in an HTML file with JSON objects

    javascript,json,replace
    I am writing some Javascript to: Read in and Parse a JSON file Read in an HTML file (created as a template file) Replace elements in the HTML file with elements from the JSON file. It is only replacing the first element obj.verb. Can someone please help me figure out...

    Replace string to the target format

    .net,regex,vb.net,string,replace
    Is there a way to replace a string using regex or string replace COND X > 49 300000 200000 The expected format is COND(X > 49,300000,200000) My current approach is to do string.Split(" ") and convert it to list and insert the braces at the proper indexes. But the problem...

    RegEx replace returns unexpected result without .*

    javascript,regex,replace,capture-group
    I'm trying to create a regualr expression that does the following transformations: Apple Orange > AO Load Module > LM anApple Orange > O toLoad Module > M I found a suitable pattern, but noticed a strange behavior. Here's my initial try: /^([A-Z])?[^ ]* ([A-Z])/ Running a replace on the...

    Is it possible to change ONE line in a txt file WITHOUT reading and writing the whole file (Java)?

    java,file,text,replace,line
    Say I have a text file: I love bananas. <age> 23 </age> years old. I like beaches. All I want to do is open said file and change the age to 24 or 25. Any way to do that in Java WITHOUT reading a writing the whole file? I know...

    Search and replace all php_short_tag that is

    php,regex,replace,php-shorttags,shorttags
    I did not want the hasle of turning on php_short_tag in php.ini and also i wanted to use xml without issues which short tags could introduce, so instead i replaced every occurance of a short tag in the code by using search and replace. I thought i should share it...

    Replace text between two special characters

    regex,r,text,replace
    I have a character vector as: x<- "\t\t<taxon id=\"TOT_F50\"/>" and y<- "TOT_A01" and I want replace TOT_F50 with the text in y ("TOT_A01"). Do you know how to replace the text between " and \ (i.e. "TOT_F50) ? ...

    MySQL wildcard replace

    mysql,replace,wildcard,placeholder
    Hi i need help with a MySQL query. Is it possible to do some wildcard replace for a string like the example below? String:                        example.com/folderone/some/path/to/file.pdf String:                        example.com/foldertwo/some/path/to/file.pdf Replace: newsite.com/some/path/to/file.pdf newsite.com/some/path/to/file.pdf newsite.com/some/path/to/file.pdf To remove the folder and change the domain but keep the path. In this case...

    How to remove all characters before a specific character in Python?

    python,string,replace
    I'd like to remove all characters before a designated character or set of characters (for example): intro = "<>I'm Tom." Now I'd like to remove the <> before I'm (or more specifically, I). Any suggestions?...

    javascript replace dot (not period) character

    javascript,regex,replace
    I have some text being rendered that has an inline list with the bullet points notated by the "•" character, all on one line of text. It's ugly, but I don't want to change the source data. So I thought I'd just do a quick javascript replace to insert breaks...

    Regex to remove `.` from a sub-string enclosed in square brackets

    c#,.net,regex,string,replace
    I have this regex in C#: \[.+?\] This regex extracts the sub-strings enclosed between square brackets. But before doing that I want to remove . inside these sub-strings. For example, the string hello,[how are yo.u?]There are [300.2] billion stars in [Milkyw.?ay]. should become hello,[how are you?]There are [3002] billion stars...

    Regex capture and replace %20 after last forward slash

    regex,bash,perl,replace,command-line
    I have a tsv file with a lot of HTML inside. I need to replace %20 after last forward slash of href attributes of non .jpg links. I'm trying with Perl on command line, I need help with the regex. I have tried some regex, this is in the live...

    conditional replace based off prior value in same column of pandas dataframe python

    python,pandas,replace,fill,calculated-columns
    Feel like I've looked just about everywhere and I know its probably something very simple. I'm working with a pandas dataframe and looking to fill/replace data in one of the columns based on data from that SAME column. I'm typically more of an excel guy and it is sooo simple...

    Extract Cells content in the first Excel File based on Worksheet in another File

    excel,function,excel-vba,replace
    In a first Excel File multiple Cells in Column C contains the address and the name of a company; I want to keep only the company name. For that, I have another Excel file (I'll call it "Dictionary"), which has a particular structure like the following: Column B : Name...

    How to alter dynamic/live element attributes - (replaceWith()) used

    jquery,dynamic,replace,live
    I am having a hard time wrapping my head around how to access and alter attributes of HTML content added in place of a placeholder element using replaceWith. Here is the scenario: Here is the HTML (kept in a php file) that replaces the '#null_item' element in the subsequent HTML...

    Replace the contents of a vector with the values of a matrix

    r,matrix,vector,replace
    Well, I hope I explain it simple: I have a matrix: matrix(c("a","b","c",1,2,3), nrow=3, ncol=2) with output: [,1] [,2] [1,] "a" "1" [2,] "b" "2" [3,] "c" "3" I have a vector, for example: vector1 <- c("b", "a", "b", "c") I want that another vector to pick the values associated of...

    SQL bypass REPLACE by CASE statement

    sql-server,tsql,replace,case,sql-server-2014
    I have data where some records contain blank rows (=no space, no NULL). E.g.: LOCALE en-es en-uk uk-uk When I want to select that blank row, it's easy with: SELECT LOCALE FROM ABC WHERE LOCALE = '' But when I try to replace it as follows, it does not work,...

    jquery losing value of $(this) on ajax request [duplicate]

    javascript,jquery,ajax,replace
    This question already has an answer here: Using selectors and $(this) in Jquery Ajax 2 answers Hi I am using jquery to make an ajax request to the database to add and remove favourites from the database. This works fine however I want to replace part of the href...

    Xpath for Find & Replace?

    xml,xpath,replace
    Fellow Forum Members, I'm new to Xpath and have the following question. Let's say for example I have 300 separate XML files and I need to make a global text change that may impact only 40 of the XML files. Is it possible using Xpath to perform a find &...

    Notepad++ - Find and replace both opening and closing tags while keeping the content intact?

    regex,replace,notepad++
    Let's say I wanted to replace something like this: \section{Introduction} with this: <h1>Introduction</h1> in notepad++. Essentially, find and replace all the opening tags (in this case the "\section{" part) and closing tags (the "}") with different opening and closing tags, Something like this. Except, of course, the text in between...

    Change/replace part of an URL contained WITHIN a function

    javascript,replace,google-spreadsheet
    Not sure if this is even possible. But ideally, I'd like visitors to my site to be able to type a unique identification number in an input field, click submit, and have another script replace the Google sheet reference ("DATA1") with their own ID number. So, effectively change the queried...

    Replace loop in Stata

    replace,stata
    I have two variables: patient id and date. Many patients on my database are duplicated. I want to keep the duplication, but apply to each patient the earliest appearing date. Ex: ID Date 1 8/9/07 1 6/3/07 1 11/15/08 2 8/6/06 2 8/6/06 2 11/5/09 would become ID Date 1...

    Select Concat Substring and Replace in MySQL

    mysql,string,replace,concat
    I have a .sql file that needs all the extra characters removed and just the text left. So anything inside the " ". An example of the TEXT field in the column is a:1:{i:0;s:9:"test word here";} a:1:{i:0;s:11:"test words here too";} So I would want the words. test word here. and...

    Regex replace linebreak and comma

    javascript,regex,replace
    i've a question about regex, i've a text and it looks like below : car,model,serie ,Mercedes,324,1, ,BMW,23423,1, ,OPEL,54322,1, it should look like: car,model,serie Mercedes,324,1, BMW,23423,1, OPEL,54322,1, so without commas at the beginning of the text. What i tried : var str2 = str.replace(/\n|\r/g, ""); but somehow, i couldn't add comma...

    Efficient means of mass converting >600,000 different find and replaces within one file

    replace
    I am trying to convert a map file for some SNP data I want to use from Affy ids to dbSNP rs ids (ftp://ftp.cephb.fr/hgdp_supp10/Harvard_HGDP-CEPH/, specifically ftp://ftp.cephb.fr/hgdp_supp10/Harvard_HGDP-CEPH/all_snp.map.gz). I am trying to find an effective way to this. I have the annotation file for the Axiom Human Origins array from which the...

    Java replace every Nth specific character (e.g. space) in String

    java,regex,string,replace
    I am trying to learn regular expressions and the code below replaces every other whitespace with an underscore but I am trying to replace every third white space. String replace = deletedWords.replaceAll("(?<!\\G\\w+)\\s","_"); Ex. output I get: "I have_been stuck_on this_problem forever" Ex. output I want: "I have been_stuck on this_problem...

    Replace method that adds an incrementing number to a repeated string

    javascript,node.js,methods,replace
    I have a document with a bunch of <a id="r"></a> tags, and want to add an incrementing number to each, so, <a id="r1"></a>... <a id="r2"></a>, etc. The loop that I currently have, doesn't seem to work. function(doc) { for (var i = 1; i <= doc.length; i++) { var number...

    String.replace() isn't working like I expect

    java,string,replace
    I am not understanding how to use the String.replace() method. Here is the code: CharSequence oldNumber = "0"; CharSequence newNumber = "1"; String example = "folderName_0"; System.out.println("example = " + example); example.replace(oldNumber, newNumber); System.out.println("example.replace(oldNumber, newNumber);"); System.out.println("example = " + example); And it's outputting: example = folderName_0 example.replace(oldNumber, newNumber); example =...

    Fastest way to remove 'extra' spaces (more than 1) from a large range of cells using VBA for excel

    excel-vba,replace,trim,spaces
    I've been looking around and haven't found a great answer to the question on how to remove extra spaces from a large range of cells containing text strings. Let's say 5000+ cells. some ways I have tried include: For Each c In range c.Value = Trim(c.Value) Next c and For...

    converting [b] to

    php,replace
    I don't have much experience at all with patterns and preg_replace so I know I'm doing it wrong. But I'm not sure what the proper syntax should be. In this instance I'm trying to convert [/b] to from a form submission. Here's my best attempt, which obviously is incorrect: $patterns...

    Replacing alternate spaces with newline?

    unix,replace
    I am trying to replace the alternate spaces with newlines using UNIX. I tried using tr command in UNIX but was unable modify it to replace alternate spaces. Sample input: 0 1 2 3 4 5 Sample output: 0 1 2 3 4 5 How do we achieve this ?...

    How to replace a block matrix with a new one?

    matlab,matrix,replace,list-manipulation
    I have an image size 128*128, I divided into 32*32 non-overlapping blocks, the problem is that I want to change the values of a specific or choosing block (the first or the 3rd.. for example) and getting a block with new values then replace it in my image. Do you...

    Regex Lookahead/behind to find character unless followed by the same

    regex,vb.net,replace,replaceall
    I'm really not good with Regex and have been messing about to achieve the following all morning: I want to find unicode characters ie "\00026" in an SQL string before saving to the database and escape the "\", by replacing it with "\" unless it already has two "\" characters....

    Replace numbers with Boolean in r

    r,csv,replace,weka
    I want to use weka to predict future instances. I have a csv file and a small portion of it is as following: I used r to read the file but I am not sure how to substitute the zeros with "No error" and anything besides zero to "Error". I...

    Replace string if the string is not part of a larger string using regex in javascript

    javascript,php,regex,string,replace
    I'm trying to write a function which would Uppercase some words in a textarea but I'm having trouble, as these words could be part of other words and I only want to uppercase them when they are standing alone. E.g.: I want to uppercase OR but only when not in...

    Splitting string before name of month with regex

    python,regex,python-2.7,replace,data-cleaning
    I have a bunch of lines with random text, and at the end of each line, a timestamp. I am trying to split these lines right before the timestamp. Current output: Yes, I'd say so. Nov 08, 2014 UTC Hell yes! Oct 01, 2014 UTC Anbefalt som bare det, løp...

    How to extract single-/multiline regex-matching items from an unpredictably formatted file and put each one in a single line into output file?

    linux,shell,unix,replace,grep
    I have a very huge file which looks like this: <a>text</a>text blah <b>data1</b>abc<b>data2</b> <b>data3</b>blahblah <c>text</c> <d>text</d> <x>blahblah<b>data4 data5 data6</b> <b>data7 </x> That is, its formatting is unpredictable. I need to extract each <b>...</b> item (it might contain multiline text!) and put every one of them in a single separate line....

    Jquery allow only float 2 digit before and after dot

    jquery,regex,replace
    i have to allow only number like these: 2 or 45 (from 0 to 99) 2.50 or 35.75 (2 digits before dot and 2 digits after) Someone can help me? I could limit only int in this way: $('#valueSconto').on('input', function () { this.value = this.value.replace(/[^0-9]/g, ''); }); ...

    Replace list of emojies in JavaScript

    javascript,jquery,regex,replace
    I have a list of emojies like: var emojies = ["smile", "smiley", "grin", "joy"]; And I want to detect and replace the :emoji_name: by <span class='emoji emoji_name'></span> with a function, for example, if text is: Hi guys! :smile:, replace the :smile: by <span class='emoji smile'></span> and i guess regex solve...

    Using ant.replace in gradle

    replace,ant,gradle
    I want to use ant's replace task to replace token in one of the files like this: version.txt version.number=${versionNumber} build.gradle task writeVersion { ant.replace { file 'version.txt' token 'versionNumber' value '1.0.0' } } but it is giving me following error :- A problem occurred evaluating root project '1.01-Exercise-RunYourFirstTask'. > replace...

    stringByReplacingCharactersInRange does not work?

    ios,string,swift,replace
    I am attempting to replace a character with another one. For some reason stringByReplacingCharactersInRange does not work. I have not found a simple explanation on how to resolve this issue. var binaryColor: String = "000" (binaryColor as NSString).stringByReplacingCharactersInRange(NSMakeRange(0, 1), withString: "1") println("This is binaryColor0: \(binaryColor)") The result is 000 and...

    Calling bash function in perl find replace

    bash,perl,replace
    I'm a scripting noob and trying to get this find/replace working that injects salt strings in a wp-config.php file, replacing multiple placeholders. #!/bin/bash -e function salt() { uniqSalt=$(cat /dev/urandom | env LC_CTYPE=C tr -dc "a-zA-Z0-9!@#$%^&*()-_ []{}<>~\`+=,.;:/?|" | fold -w 64 | head -n 1) echo $uniqSalt } perl -pi -e...

    Text replacement from a string in php

    php,arrays,regex,string,replace
    How do I replace the square bracket and its contents in php. For example I would like to output something like // 'Hello World Today Hello Everybody Anybody' when I echo $txt. $txt = 'Hello World [this-echo] Hello Everybody [nobody]'; ...

    Regular expression, match error

    regex,replace,match
    i just started with regular expressions and went into trouble by writing one for a case i would need. Here is my problem. I wrote this simple regex: (<img).+[>] it match for the most cases, but not for the case if something is between. Here is a image for you...

    Find and replace entire value in R

    regex,r,replace
    I'm looking for a way to use the find and replace function in R to replace the entire value of a string, rather than just the matching part of the string. I have a dataset with a lot of (very) long names, and I'm looking for an efficient way to...

    Replace forward slash with jQuery

    javascript,regex,string,replace
    This is my string: hello/page/2/bye This is what I would have (please note that "2" could be any number, "page" is always "page": hello/bye How can I do with str.replace() using jQuery?...

    Replace a random block of characters in a string in R

    regex,r,replace
    I have a text and I want to replace a text block in a line, like that: "\t\t\tFGHGFJKJKJKGDSJS" with x= "ABCCCBBHHJJJH" I'm interested in changing just the text block (FGHGFJKJKJKGDSJS) without modyfing the presence of other special characters. So obtaining: "\t\t\tABCCCBBHHJJJH" Do it exist a way to replace FGHGFJKJKJKGDSJS without...

    How to Avoid the string from number(for rupees) in c#?

    c#,wpf,c#-4.0,replace,decimal
    am new in c# so how to replace the string for example:- label1.Content = "Bal.Rs." + 100; How to get the 100 only while we save from label1.Text???...

    Python: Replace “wrong” floats by integers inside string

    python,string,replace,floating-point,integer
    I'm trying to replace all useless floats in a string (1.0, 2.0 etc.) by integers. So I'd turn a string like "15.0+abc-3" to "15+abc-3". Do you know a way to do that? I hope you understood my idea. If you didn't feel free to ask....

    replace() function recodes entire column

    r,replace
    I am using R, and need to recode some variables in a list. The list is as follows: > list1 Group.1 x 1 4000 2 3890 Where in the Group.1 column I would like to replace any instance of 1 with male, and 2 with female. I have tried to...

    Python - Opening and changing large text files

    python,replace,out-of-memory,large-files
    I have a ~600MB Roblox type .mesh file, which reads like a text file in any text editor. I have the following code below: mesh = open("file.mesh", "r").read() mesh = mesh.replace("[", "{").replace("]", "}").replace("}{", "},{") mesh = "{"+mesh+"}" f = open("p2t.txt", "w") f.write(mesh) It returns: Traceback (most recent call last): File...

    Using R to repeatedly replace words

    r,loops,replace
    I have a sentence and I printed it in two lines: cat("Today is Monday and it is sunny.\nMonday is a sunny day\n") and I have two lists: day<-c("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday") weather<-c("sunny", "cloudy", "rainy", "stormy","sunny", "cloudy", "rainy") I am trying to produce a text file which would...

    String Replace Java Function

    java,string,class,replace,bukkit
    I tried to Replace in multiple classes an multiple Strings with a function Why does this example not Work? public static String symbole(String sym) { sym = sym.replace("&" , "§"); sym = sym.replace("[<3]" , "\u2764"); return sym; } String test = "This Dont work... why [<3]"; symbole(test); how can...

    how to replace strings in a file by other strings in java

    java,string,file,replace
    I have a file which every line contains strings like that : usual,proper,complete,1,convenient,convenient,nonprob,recommended,recommend I want to replace every word by such a code like that : 1000, 100, 110, 110, 111, 001, 111, 111, 1000 Here is the code that I used but it still incomplete : public class Codage...

    Return what was replaced in SQL

    sql,sql-server,regex,tsql,replace
    I'm trying to remove personal information (strings) from a database, ie. usernames, addresses, etc for testing purposes. Then I'd like to use the string that was removed to search back through the DB to see if it occurs elsewhere. I'm using SQL Server Management Studio. For a table MyTable, and...

    Replace integers in a string using Visual Basic

    vb.net,string,replace,integer
    I am trying to replace integers in a string using Visual Basic and can't seem to get it just right. This is what I currently have: lblNewPassword.Text = txtOrigPassword.Text.Replace("[0-9]", "Z") I have also tried: lblNewPassword.Text = txtOrigPassword.Text.Replace("#", "Z") And: lblNewPassword.Text = txtOrigPassword.Text.Replace("*#*", "Z") ...

    Replacing values in a matrix by specified values

    matlab,for-loop,replace
    I have a three dimensional array of simulated data (dimensions are 10000-by-16-by-312 or #trials by TimeSeries by horizons). I would like to replace values above / below a pre-specified threshold with the threshold values. I have calculated the threshold values for each individual time series in MinAcceptableVal(:,i) and MaxAcceptableVal(:,i). When...

    How do i remove the large leading space in the output of this code for variable a

    java,string,replace
    I'm experimenting with string and string replacement for example in application to strip bad language or malicious code characters from strings . this is working but the output when compiled leaves a large space prior to the output "vilification managed..." //import java.util.regex.Pattern; class grandaddy { public static void main (String...

    Replace the characters in every line of a file, if it match a condition - Unix

    unix,replace,sed,match,condition
    I have a file "dummy" in which: If 15 character of the file matches with "R" and 28 character of the file matches with "D" then 53-56 characters should be replaced with 0. I have tried using the below script, but it's not working. for i in `cat dummy` do...

    Find and replace in an AS3 String

    string,actionscript-3,replace,find
    I want to find the "(*" string in another string and then replace it with the < and / one but the method replace() can not do it. Sorry, but I can not write the string in the description together :D Here is my code: //Call the method like.. trace(searchandreplace("(*Foo)"));...

    Delete word from a line in a text file

    java,string,file,replace
    I am trying to delete the words alle 30 Min in the lines of my timetable. Currently 30 and Min is being deleted but not the word alle. How can I fix that? I appreciate any help. Sample apple 05:05 05:35 06:05 06:35 07:05 07:35 08:05 17:05 17:35 18:05 18:35...

    PHP Replace binary file at hex address [closed]

    php,replace,binary,hex,preg-replace
    I want to modify a binary file server side of aprox. 700kb to change an url in it than save it. My first idea was to use bin to hex and preg_replace to replace url in binary. The adress for the url in binary is always the same, but i...