Can I match and replace a text pattern in a MYSQL select?
EDIT
For now it looks like the answer is: Can't be done,
since you can't capture what was matched (from Eric's answer / comments). For now I will look into adding a lookup table.
Simplified example:
The MySQL table Coleridge holds many strings like:
text
------------------...
I need to replace many different sub-string in a string in the most efficient way.
is there another way other then the brute force way of replacing each field using string.replace ?
...
I want to implement a basic search/replace translation table in C; that is, it will read in a list of pairs of words from a config file, and go through a text received at runtime, replacing each source word it finds with the corresponding target word. For example, if my user-input text was
"Hello world, how are you today?"
and my conf...
I want to replace certain characters in an input string with other characters.
The input text has Microsoft left and right smart quotes which I would like to convert to just a single ".
I was planning on using the Replace operation, but am having trouble forming the text string to be searched for.
I would like to replace the input seq...
Using VB.Net I'd like to be able to replace a range of characters in a string in a single line of code.
i.e. something like
Dim charsToReplace as string = "acegi"
Dim stringToBeReplaced as string = "abcdefghijklmnop"
charsToReplace.ToArray().ForEach(Function (c) stringTobeReplaced = stringTobeReplaced.Replace(c, ""))
however, this ...
My shared hosting account with a number of websites was compromised. Some malware on my PC, which I probably got through downloading a PDF file, found all my FTP passwords and happily went about its business of inserting some code into all index.* files on the server. I now got rid of this malware, and I am ready to change all FTP passwo...
How to easily/quickly replace float's for doubles (for example) for compiling to two different targets using these two particular choices of primitive types?
Discussion:
I have a large amount of c# code under development that I need to compile to alternatively use float, double or decimals depending on the use case of the target assembl...
I'm trying to update a series of xml files by changing names that they reference. I have a table of names that have changed, column for the current name and a column for the name to replace with.
I looked for ways to script search and replace and found sed. It seemed like a good choice until I ran my first attempt. On inspecting the fi...
Hello,
I am trying to replace characters inside a math environment with their boldface versions. Unfortunately, these characters occur inside the rest of the text, as well.
My text:
text text text text Gtext G G text ....
\begin{align}
f&=gG \\
G &= tG
\end{align}
text textG text $G$ text.
Every G inside
\begin{align} \end{a...
Hi!
I'm trying to make a simple php script to find all src attributes from all images in a html text and then replace all found srcs with some text after making some conditional changes.
Something like this:
@preg_match_all('/<img\s src="([a-zA-Z0-9\.;:\/\?&=_|\r|\n]{1,})"/isxmU', $body, $images);
now i've all srcs into the $images ...
Hi there,
I want to convert all texts in a string into html entities but preserving the HTML tags, for example this:
<p><font style="color:#FF0000">Camión español</font></p>
should be translated into this:
<p><font style="color:#FF0000">Camión español</font></p>
any ideas?
...
We have a database where every table name starts with WW.
I want to display an SQL on a web page, but wrap each table name with a link.
For example:
"select * from wwx_something where ..."
Should be transformed into:
"select * from <a href='/table/wwx_something/'>wwx_something</a> where ..."
There might be several tables, of course...
How can I replace all occurences of java substrings like stuff="-9888777666" , stuff="123", with the substring stuff="0"? The double quotes are actually a part of the string.
...
Hi everyone,
I am trying to replace the backslash (escape) character in a Javascript string literal.
I need to replace it with a double backslash so that I can then do a redirect:
var newpath = 'file:///C:\funstuff\buildtools\viewer.html'.replace(/\\/g,"\\");
window.location = newpath;
However, it seems to have no result.
I don't...
Hello
I have string like this:
G:\Projects\TestApp\TestWeb\Files\Upload\file.jpg
How can i do to remove all text before Files (G:\Projects\TestApp\TestWeb)?
The search way before files can change, so i can't count signs and remove after 20 signs.
Thanks for help :)
...
Hi,
My goal is to replace the links in the database with a catchall link. I generally use the REPLACE command for replacing string in the database, but this time I am having difficulty because in order to find the links I need to use regular expressions, and that is simply not working out:
UPDATE node_revisions SET body = REPLACE ( `bo...
I'm using rake to create a Table of contents from a bunch of static HTML files.
The question is how do I insert it into all files from within rake?
I have a <ul id="toc"> in each file to aim for. The entire content of that I want to replace.
I was thinking about using Nokogiri or similar to parse the document and replace the DOM node...
I have an xml file (Student.xml) like this
<student>
<studentinfo>
<name>
<first>John</first>
<last>Doe</last>
</name>
<gender>male</gender>
</studentinfo>
</student>
and my php code
<?php
$dom = new DOMDocument;
$dom->load('Student.xml');
$student = $dom->documentElement;
...
I have a list of 400 strings that all end in "_GONOGO" or "_ALLOC". When the application starts up, I need to strip off the "_GONOGO" or "_ALLOC" from every one of these strings.
I tried this:
'string blah = Regex.Replace(string, "(_GONOGO|_ALLOC)", ""));'
but it is MUCH slower than a simple conditional statement like this:
if (strin...
I am looking for a solution/best practice to do a swap of values for a status flag.
The status INT(3) in mysql has a few values, and I'd like to be able to swap the LIVE and NOT_LIVE values around, without interrupting what other bitwise values are in there.
If it was a flag field, as in 0 or 1, it is easy:
'status' NOT 'status'
I w...