Replace the text in the string
I would like to know how I could continue to write something that would allow a string of variable length to replace in a longer string, subject 'inner chain' is bounded by something.In other words, assume the string is something like
Tiger Woods +15/09/2010+
where the character was more used as a delimiter. I would like to extract this possibility to leave Tiger Woods. I can't do a simple substr, because the string can be+15/09/2010+ Tiger Woods
. It could even beTiger +15/09/2010+ Woods
. Or it could beTiger Woods +September 2010+
. In all cases, the correct return is plain Tiger Woods.Point is, I want to remove everything between the two more brands wherever they appear and return what is left.
I'm guessing that maybe that's a job for regular expressions, but I dread, so yes, because I'm not very good for them!
Any help appreciated, so. :-)
and to be complete - as says hoek - regular expressions can do it well.
SQL> with t as (
2 select 'Tiger Woods +15/09/2010+' str from dual union
3 select '+15/09/2010+ Tiger Woods' from dual union
4 select 'Tiger +15/09/2010+ Woods' from dual union
5 select 'Tiger Woods +September 2010+' from dual
6 )
7 select regexp_replace(str,'\+.+\+')
8 from t;
REGEXP_REPLACE(STR,'\+.+\+')
--------------------------------
Tiger Woods
Tiger Woods
Tiger Woods
Tiger Woods
4 rows selected.
Although you will notice let outdoor spaces, you can do another to delete extra spaces.
Tags: Database
Similar Questions
-
Search and replace the string formatting
Hello
I try to do a search and replace the formatting of a string.
In the example, I'm looking for the string 'SUCCESSFUL', but it must also begin by usbflash and some number + PASSED.
I can't get the format to have a number between 1 and 99. The number of replacements should add up to 6 in this case. I tried with \d for any number, and I also tried [1-99].
Make a right-click on the function search and replace the string. There is an option to use regular Expressions. Then give it a try.
EDIT: You need to set the entry replace all to TRUE.
-
How to replace the string "\" on json webservice?
Hello
I have problem with this json
"{\"search_result\":[{\"name\":\"Mall Summarecon\",\"category\":\"BusinessEntity\",\"id\":\"1\"},{\"name\":\"Bamboo Dim Sum\",\"category\":\"BusinessEntity\",\"id\":\"2\"},{\"name\":\"Dimsum Ceker\",\"category\":\"Item\",\"id\":\"1\"}]}"
I want to replace the string "\".
the json are already working on my app via .cpp file
I already add json.replace on my qml
function simpleSearch(response){ indicator.stop() model.clear() console.log("Response: "+response) var json = JSON.parse(response) json = json.replace('\\', ' ') // this is how the way i replace if (json == "[]") notFound.visible = true else model.append(json.search_result) }
but still does not work
is there a different way to replace it?
Thank you
Change your simpleSearchFinished as follows
....simpleSearchFinished() { QNetworkReply *reply = qobject_cast
(sender()); if (!reply->error()){ QByteArray response = reply->readAll(); response.replace("\\", ""); if (response.startsWith("\"")){ response.remove(0, 1); } if (response.endsWith("\"")){ response.remove(response.length()-1, 1); } emit simpleSearchDone(response); }else{ const int httpCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); qDebug() << "ErrorCode" << httpCode << endl << \ "ErrorString" << reply->errorString(); emit error(httpCode, reply->errorString()); } reply->deleteLater(); manager->deleteLater(); } and QML
function simpleSearch(response){ indicator.stop() model.clear() var json = JSON.parse(response) if (json){ // is VALID/PARSED model.append(json.search_result) } }
As I wrote, it is not a good workaround solution. The best is to send VALID JSON string directly from your server. But it works
-
Replace the string value of table
with cte as)
Select val '123', 'abwec' double val1
Union of all the
Select "456" val, "mowerw" double val1
Union of all the
Select val '709', 'wkwere' double val1
Union of all the
Select val '078', 'awerwewerwreq' double val1
)
Select * from cte;
-incoming string
"asdasd123ewrwer@87w8eopiu456werwer@asdwer709@ewrwerewrwqqwezxder078 @..."
need to replace like 'abwec' 123 and 456 as "mowerw" and 709 as wkwere and 078 as 'awerwewerwreq '.
How to replace the string value of the string
I'm going to the table which will have mapping information I need to see the incoming string and replace the appropriate value of the val to val1
something like
Of
"asdasd123456werwer@asdwer709@ewrwerewrwqqwezxder078ewrwer@87w8eopiu @..."
TO
"asdasdabwecewrwer@87w8eopiumowerwwerwer@asdwerwkwere@ewrwerewrwqqwezxderawerwewerwreq@..."
By using the TYPE clause.
with cte as
(
Select val '123', 'abwec' double val1
Union of all the
Select "456" val, "mowerw" double val1
Union of all the
Select val '709', 'wkwere' double val1
Union of all the
Select val '078', 'awerwewerwreq' double val1
),
input_tbl
as
(
Select "asdasd123ewrwer@87w8eopiu456werwer@asdwer709@ewrwerewrwqqwezxder078 @..." input_str
of the double
)
Select max (input_str) Dungeon (first order by desc NWR dense_rank) input_str
de)
Select rno, input_str
de)
Select rownum NWR
val
val1
input_str
count (*) over() cnt
from cte
Cross
Join input_tbl
)
model
dimension (NWR)
measures (val, val1, cnt, CAST (input_str AS VARCHAR2 (4000)) input_str)
(
input_str [any] = replace (nvl (input_str [cv () - 1], input_str [cv ()]), val [cv ()], val1 [cv ()])
)
)
-
Replace the string with the formatted text
Hello all - I'm back to my beloved project...
I want to replace a string by a TextSelction (formatted text) and began with the famous feature of Jang FindAndReplaceString.
Since my replacement comes from another document (sourceDoc), I edited to targetDoc activeDoc and introduced a second document (sourceDoc).
The replacePara actually comes from a stone where he had been placed to avoid switch backwards between the documents in a book (where to find and replace) and source documents. In another function, I learned that information on the table requires the sourceDoc must remain open.- Of course, everything works fine until I want to insert the replacelement:
erase line 26 is the string - Given that I do not insert a string, I skip lines 28 and 29 and try try line 30
- On line 30 DocumentSource is Document object and replacePare object TextSelection. However, sourceDoc.replacePara is not set and
- (as a result?) line 31 past the current contents of the Clipboard.
Of course, there is a fog around me... and I need some sunshine.
function FindAndReplacePara (targetDoc, findString, sourceDoc, replacePara, loopMax) { var tr = new TextRange(); var restoreTR, frame = 0, loopCounter = 0, replacementCounter = 0; var findParams = new PropVals(); var firstPgf = targetDoc.MainFlowInDoc.FirstTextFrameInFlow.FirstPgf; tr.beg.obj = tr.end.obj = firstPgf; // set up the starting text range as the very beginning tr.beg.offset = tr.end.offset = 0; // of the flow. We'll move straight from beginning to end. trSaved = tr // to come back after work findParams = AllocatePropVals(2); findParams[0].propIdent.num = Constants.FS_FindText; findParams[0].propVal.valType = Constants.FT_String; findParams[0].propVal.sval = findString; findParams[1].propIdent.num = Constants.FS_FindCustomizationFlags; findParams[1].propVal.valType = Constants.FT_Integer; findParams[1].propVal.ival = Constants.FF_FIND_CONSIDER_CASE; FA_errno = Constants.FE_Success; // errno global, to be used to track the progress of the find and replace tr = targetDoc.Find(tr.beg, findParams); // and do an initial find to get started. while(FA_errno === Constants.FE_Success && loopCounter++ < 2*loopMax) { //find and replace loop as long as we keep finding targetDoc.TextSelection = tr; // set up the text range to clear the original text targetDoc.Clear(0); // clear it // targetDoc.AddText(tr.beg, replacePara); // insert the new text at the original beginning of the text range // tr.beg.offset += replacePara.length; // lets jimmy the text range in memory to place it directly after targetDoc.TextSelection = sourceDoc.replacePara; // paste the whole replacement paragraph targetDoc.Paste (0); // <-- Current contents of clipboard is pasted !!!! if(FA_errno === Constants.FE_Success) { // increment our return counter replacementCounter++; } FA_errno = Constants.FE_Success; // ... find the next instance. We'll reset FA_errno again just in case tr = targetDoc.Find(tr.beg, findParams); // something screwy happened while we were replacing text. } targetDoc.ScrollToText(trSaved); // we're done. Restore the document to it's original area of display return replacementCounter; } // --- end FindAndReplacePara
Hi Klaus,
Thanks for the explanation. I remember something like that GetTabRange of the way back. You have been quite patient and persistent with this project, indeed.
So, as we are dealing with ranges of text here, I think that the only simple approach is to perform a copy and paste. There is no way to save a 'formatted' in a variable. The only super precise way would be to get a data structure of each text range TextItems in the sourceDoc, then meticulously recreate every element of the targetDoc. It would be very complicated, I think, so copy and paste seems the most logical. I wonder, though, if Miss me something, because I think that maybe you would have tried already so yes (?)
In any case, I would do something like that, from line 30 of your original code sample (code untested here):
App. ActiveDoc = sourceDoc;
sourceDoc.TextSelection = replacePara;
sourceDoc.Copy (0);
App. ActiveDoc = targetDoc;
targetDoc.Paste (0);
... etc.
Does make sense, or am I barking the wrong tree, as they say?
Russ
- Of course, everything works fine until I want to insert the replacelement:
-
Replace the strings inside SWF's AS2/3
There are, on some Board there are a few foreign flashes that predate the internet and effectively anonymous pertaining to the creator, if someone used a program to get the strings in the SWF file (programmed in AS3), machine to translate them and put back them.
Deal is a machine translation. It's funny, but it's still wrong and I would like to do a good job of translating.
So to get to the point, I would like to know where I might be able to find a program that can get the strings inside a SWF file that is programmed in AS2 or AS3, show them to me and I would like to replace them with custom text. The reason why I want to do it this way is that I must not decompile SWF. Decompile a SWF is bound to generate errors and I could not have certain fonts inside so I also have little to do with the opening of the thing I can.
I tried a few solutions, including FLASM (only works on AS2) and others don't bother naming such that they are no longer capable of displaying the AS3 code and not edit or replacement of classes.
I'm not 'try' anything. I inform you of your options.
If you do not find the source files and that you can not use a decompiler, you cannot change the source code.
-
Find and replace the string function replaces line breaks when I only replaced spaces?
I need to replace all instances of a space or a series of spaces to a line with commas (or tabs) multi string so I can throw in a worksheet.
I use the regular expression [\s]+ and it works, but it is also to replace the end of lines (\r\n) too.
How can I replace the spaces but leave the end of the lines intact?
Right-click on the search string and to take '-' code display. Enter the space character (\s) correctly - you \\s right now.
-
Search and replace the string in a column
Hello
In the table the data stored with "" (double quotes), I need to remove these quotes please suggest me how to remove
Select the address of TECH_SOURCING_EMPLOYEE_DETAILS
"No. 12/32"-> data recorded in this format in the table. I need to remove the double quotes
Thank you
SudhirHello
UPDATE to modify existing rows in a table
REPLACE to delete a given sub - a to a string.UPDATE tech_sourcing_employee_details SET address = REPLACE (address, '"') WHERE INSTR (address, '"') > 0 -- Maybe ;
This will remove all the quotes of the address.
If you want to remove the quotes only from the beginning and the end of the string, then use TRIM instead of REPLACE:UPDATE tech_sourcing_employee_details SET address = TRIM ('"' FROM address) WHERE INSTR (address, '"') > 0 -- Maybe ;
The WHERE clause is only for effectiveness.
So, whenever the column contains quotes, of the double quotation mark is always the first character in the string, then you can change the WHERE clause to:WHERE address LIKE '"%' {code}
-
Search and replace the string from a result
Hi all
I want to search a "("or ")" of the chain and all want the string before replacing "(" with a blank space...
for example
If the result comes like this
name
12 #122 (on the opening balance)
I want the result as
name
on the opening balance)
means
12 #122 is replaced by "" how
thanking you
Gaurav SontakkeLike this?
WITH t AS (SELECT '10 #10 (moving standard to msp1004)' str FROM DUAL UNION ALL SELECT '13208 #0' str FROM DUAL UNION ALL SELECT '2002-02-22 #10' str FROM DUAL) SELECT SUBSTR (str, 1, INSTR (str, '#') - 1) FROM t
-
Hey all,.
I need to replace the & with a + since the & just breaks the bpel process. Any ideas on how to make a replacement string to find all the the & and replace it with the +, I looked in the transformation and the entitlement activity, but did not find all the functions to help me with this.
Any help would be appreciated.
Thank youYou can create an XSL template for string replacements, see the link given below:
http://geekswithblogs.NET/Erik/archive/2008/04/01/120915.aspxIf you are familiar with Java you can add a Java embedding activity and string replacement using the method of the replacement of the java.lang.String class.
Diakité
http://SOA-HOWTO.blogspot.com -
Replace the string on a specific line
Hi everyone thanks in advance for your time.
I have almost finished a project, (a software to manage the booking of hotel rooms and a database of passengers).
I made a function that writes a .txt file a cluster with some personal information string type fields, each field is separated by tabs, and each client separated by a line news.
Example: name address phone etc.
Robert xxxxxx yyyyyyy
Patrick xxxxxx yyyyyyy
Mila xxxxxx yyyyyyy
Now I don't know how I can do to perform a search by name and to be able to change each field.
Example:
If I search for Patrick, I want to be able to change the address or phone number or any other field.
I know how to search in a text file, until I reach the word, but I don't find a way to change the field and write once again the information in the same file in the same line of origin.
Any contribution will be great! Thanks again.
-
Hi all
I need like below. FONT-FAMILY string twice, repeat with the lowercase and uppercase, highlited blue color.
What ever after FONT FAMILY contains data must replace it with our new channel.
Select ' < P style = "MARGIN-BOTTOM: 0pt" > < SPAN style ="FONT-FAMILY: arial, calibri" data-mce-style ="-font family: arial, black, Vanguard;" > < SPAN style = "" FONT-SIZE: 14pt "data-mce-style =" font size: 14pt; "> < SPAN style =" "COLOR: #ff0000 ' data-mce-style =" color: #ff0000; ' > it is arial black14pt </span > < / SPAN > < / SPAN > < / p > '
of the double
Power required:
< P style = "MARGIN-BOTTOM: 0pt" > < SPAN style ="FONT-FAMILY: Calibri" data-mce-style ="font family: Calibri;" > < SPAN style = "" FONT-SIZE: 12pt "data-mce-style =" do-size: 12pt; "> < SPAN style =" "COLOR: #ff0000 ' data-mce-style =" color: #ff0000; "> it is arial black14pt </span > < / SPAN > < / SPAN > < / p >
Like this?
SQL > ed
A written file afiedt.buf1 with t as (select"
"as double txt).
= "" color: #ff0000; "> it is arial black14pt"
2 --
3 end of test data
4 --
5 Select regexp_replace (txt, "([Ff][Oo][Nn][Tt]-[Ff][Aa][Mm][Ii][Ll][Yy]:).*?)" ",' \1Calibri" ') as txt
6 * t
SQL > /.TXT
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
It is arial black14pt
/ SPAN > -
Replace the string, each value should double quotes around it
How can I replace this basic string with double quotes around each value?
dog, cat, john, mark
I would like to:
'dog', 'cat', 'john', 'brand '.
Thank you
-weStsIdEHello
I answered my own question. Well nice for someone else. The function ListQualify will insert what you need before and after each element of individual list.
Actually powerful enough that you can just insert double quotation marks, for example around channels and leave intact numeric values.
-weStSidE
-
Replace the string with quouts
Hi all
I use the oracle version below:
12 c Oracle database Release 12.1.0.1.0 - 64 bit Production
PL/SQL Release 12.1.0.1.0 - Production
CORE Production 12.1.0.1.0
AMT for Linux: Version 12.1.0.1.0 - Production
NLSRTL Version 12.1.0.1.0 - Production
I have a string like:
0,1,5,9,10,58... so now
I need to convert the above string in form below:
'0 ', '1', '2',' 3'... well now
Here, I want to add quotes to open and closing of all the numbers that are separated by a comma.
Select '0,1,2,3' double;
but I pulled out as:
'0 ', '1', '2',' 3'
Here, there are a lot of numbers in a string, but all are separated by commas.
Thank you
something like:
WITH the DATA (str) AS (SELECT ' 0,1,5,9,10,58' FROM dual)
Select regexp_replace (str, '(\d+)', q '{' \1'}')
from the data
/
?
HTH
-
How to write good model to replace the string after a static string?
Select regexp_replace ("Do replace not CONSTANT" VAR_123 "needs to be replaced", "CONSTANT" [A-Z0-9] ',' CONSTANT "REPLACE") twice;
The output is:
Does not replace CONSTANT 'REPLACEAR_123' SHOULD be replaced
Output available is:
Does not replace CONSTANT 'REPLACE' SHOULD be replaced
What is the right model to solve my problem?
Assistance is needed.
Concerningpossible alternatives
/* replace everthing in between "" */ select regexp_replace('Do not replace CONSTANT "VAR_123" should be replaced ' , '"([A-Z0-9_]*)"' ,'"REPLACE"') from dual; Do not replace CONSTANT "REPLACE" should be replaced /* replace UPPER letters, Numbers and Underscore after keyword CONSTANT an in between "" */ select regexp_replace('Do not replace CONSTANT "VAR_123" should be replaced ' , '(CONSTANT) "([A-Z0-9_]*)"' ,'\1 "REPLACE"') from dual; Do not replace CONSTANT "REPLACE" should be replaced /* replace alphanumerica values including underscore after keyword CONSTANT an in between "" */ select regexp_replace('Do not replace CONSTANT "VAR_123" should be replaced ' , '(CONSTANT) "([[:alnum:]_]*)"' ,'\1 "REPLACE"') from dual;
One of the problems is that did ' t take you into account how the underscore character '_' is recognized.
-
Replace the string "/ faces" when to deploy application
Hi all
I use Jdev 11.1.1.0.
When I deploy an application, so I can see from the url:
http://localhost:PortNumber / myApplication-ViewController-context-root/faces/myPage
I can change the channel 'myApplication-ViewController-context-root', but I can't change the channel 'faces '. Is there a way?
Thank youHello
In your web.xml file, you have:
Faces Servlet
faces *.
change it to what you want (as long as you do not create conflicts with other existing url mapping):
If change you it to:
Faces Servlet
/ foo / *.
You call your application with the URL:
http://localhost:PortNumber / myApplication-ViewController-context-root/toto/myPageJack
Maybe you are looking for
-
My motherboard went bad on my old computer, but the hard drive was OK. I bought a new computer and plugged my old hard drive to it via a usb adapter. I would like to import or copy my favorites from the old hard drive to my new, but I can't find wher
-
manage my hybrid HDD/SSD drive with my new Y50
new Y50 with them on board the band NVIDIA GeForce GTX 860M 2GBIntel Core i7 4700HQ (2.40 GHz)8 GB memory 1 TB HDD 8 GB SSD When I got to the machine, it was divided into two discs: Windows8_OS (C 887GB) Lenovo (D 24.9 GB) I don't see any SSD drive i
-
Hello I have a HP Pavilion g6 running Windows 7. She used to detect my HD card but I had to have the hard drive replaced and it does detect it anymore. It does not find any PC device driver. The hardware ID are: PCI\VEN_10EC & DEV_5209 & SUBSYS_16701
-
Can I share my access broadband with other users on my PC. I am running Vista.