How to replace a character in a string
Hello Powerusers
First i'me new in the applescripting so hope you can tell me a few hint to get on.
I Have been trying to find a way to replace characters in a string using applescript. but with no luck
Anybody having a script that can give me a clue on this.
I'me normally programming in windows.... yeah i know there is a first time for everything.
Okay i solved my problem but why arent the folder renamed?
property oldfolder : ""
property newfolder : ""
property SS : "."
property RS : " "
to replaceText(someText, oldItem, newItem)
replace all occurances of oldItem with newItem
parameters - someText [text]: the text containing the item(s) to change
oldItem [text, list of text]: the item to be replaced
newItem [text]: the item to replace with
returns [text]: the text with the item(s) replaced
set {tempTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, oldItem}
try
set {itemList, AppleScript's text item delimiters} to {text items of someText, newItem}
set {someText, AppleScript's text item delimiters} to {itemList as text, tempTID}
on error errorMessage number errorNumber -- oops
set AppleScript's text item delimiters to tempTID
error errorMessage number errorNumber -- pass it on
end try
return someText
end replaceText
tell application "Finder"
set these_items to the selection
end tell
repeat with i from 1 to the count of these_items
set this_item to (item i of these_items) as alias
set this_info to info for this_item
set oldfolder to name of this_info
set newfolder to replaceText(oldfolder, SS, RS)
set name of this_info to newfolder
end repeat
Similar Messages
-
How to replace a character in a string with blank space.
Hi,
How to replace a character in a string with blank space.
Note:
I have to change string CL_DS_1===========CM01 to CL_DS_1 CM01.
i.e) I have to replace '=' with ' '.
I have already tried with <b>REPLACE ALL OCCURRENCES OF '=' IN temp_fill_string WITH ' '</b>
Its not working.Hi,
Try with this..
call method textedit- >replace_all
exporting
case_sensitive_mode = case_sensitive_mode
replace_string = replace_string
search_string = search_string
whole_word_mode = whole_word_mode
changing
counter = counter
exceptions
error_cntl_call_method = 1
invalid_parameter = 2.
<b>Parameters</b> <b> Description</b> <b> Possible values</b>
case_sensitive_mode Upper-/lowercase false Do not observe (default value)
true Observe
replace_string Text to replace the
occurrences of
SEARCH_STRING
search_string Text to be replaced
whole_word_mode Only replace whole words false Find whole words and
parts of words (default
value)
true Only find whole words
counter Return value specifying how
many times the search string
was replaced
Regards,
Jayaram... -
Replacing a character in a string to another character
hi,
i need to write a function or procedure to replace the character of a string value suppose:
l_error:= 'abcdefghijklmnop' is a string
i need write a function or procedure to replace the character "c" to "z"
that data in l_error is not in any table.
thanks,
AJI want to Replace all the Existence of the word - "Test" in a string with "Test1" whereever a space exits before the word Test and someother alphabet after "Test" i.e. Test will be replaced with Test1 if a word starts with Test and contains more alphabets also. For example - TestName should be replaced with Test1Name while MyTest should not be updated to MyTest1.
I have tried to use below query which uses oracle regular expressions -
SELECT REGEXP_REPLACE('MYCOMPANY TEST TESTGEET INDIA PVT LTD TEST','\s(TEST)\w',' TEST1') FROM DUAL
Output -
"MYCOMPANY TEST *TEST1EET* INDIA PVT LTD TEST"
Here, it has also replaced the G also from TESTGEET and resulted in TEST1EET while i want TEST1GEET.
Can someone please suggest how can i do this..... may b m doing some silly mistake but sorry m a newbie to regular expression...
Thanks in advance.. -
Replacing a character in a String
Hi All,
How can I replace a character ' which appears in a String into \'There is a method in String that replaces all
occurrences of one character with anothercharacter.
It's called, hold your breath now, "replace".But tho OP wants to replace one character with two
characters :)You're right, I missed that. Well, serves me right for being sarcastic. :-) -
Replace a character in a string
Hi,
I've been tearing my hair out trying to do something very simple, replace a backslash character in a string with an underscore. I've searched online and discovered the -replace parameter which you would think would work fine but no, it seems to get in a
tizzy because the character I want to replace is a backslash and I get an error: "Invalid regualr expression pattern".
Here's what I have which produces the error:
$str = 'start\end'
$str = $str -replace '\','_'
Can someone tell me how to do this? I simply want to replace a backslash with an underscore.
thanks
Jamie
http://sqlblog.com/blogs/jamie_thomson/ |
@jamiet |
About mesod's law. I spend half an hour trying to figure this out and then as soon as I post this thread I figure it. The following works:
$str = 'start\end'
$str = $str -replace '\\','_'
$str
http://sqlblog.com/blogs/jamie_thomson/ |
@jamiet |
About me
"-replace" requires a regular expression for each argument, which is why you needed to escape your backslash with another backslash. If you use the replace() string method, you are not required to use regular expressions:
$str = $str.replace('\','_') will work exactly as you expect it to. -
Replace a character in the string using JavaScript
Hello,
I would like to ask for help. I have a field in the xml file, which contains a string, that is bound to a text box on the form.
What would be the syntax to replace a special character in the string with the carriage return?
Thank you.Huh?
I didn't post my script...
It sure is no clean programming since I just took Steve's solutions and delted the ligns I didn't want (the app allert)
Though in the end I've taken the boolean out, or better replaced it with the replacement function, it repeats the replacement no matter how much "ü"'s are in there. (I needed the boolean though, since as long as it was true, the if should be executed.)
Somehow it worked... not 100% sure why, but it worked.
if (findChar(this.rawValue)) {
function findChar(str)
{ for (var i=0; i < str.length; i++)
if (str.charAt(i) == "ü")
this.rawValue = this.rawValue.replace(/ü/,"ue") -
Replace a character from a string
Hi,
how can I replace a particular character from a string on a particular occurrence? Say for eg, if i wan to replace 'a' of second occurrence from 'abcabcabc', then what should i do? I guess the normal REPLACE function replaces every occurrence in a given string. So is there any other way to solve this?
Thanks!If you are in 9i:
Then you got to split the string into based on the nth position.
SQL> select replace('abddefabc','a','x') from dual;
REPLACE('
xbddefxbc
SQL> select instr('abddefabc','a',2) from dual;
INSTR('ABDDEFABC','A',2)
7
SQL> select substr('abddefabc',1,instr('abddefabc','a',2)-1),substr('abddefabc',instr('abddefabc','a',2)) from dual;
SUBSTR SUB
abddef abc
SQL> select substr('abddefabc',1,instr('abddefabc','a',2)-1),replace(substr('abddefabc',instr('abddefabc','a',2)),'a','X') as replaced from dual;
SUBSTR REP
abddef XbcOfcourse, later on you can join the string..
Jithendra -
How to get each character in a string
as in 'C' we use arrays to get each character of a string stored in array.how can we get each character of a string stored in a variable.
Hi,
For that you need to do offset.
for example one variable called VAR contains string 'HUMERAH'.
if you want each character of that string then you need to decalre as many variable as the number of string.
like
data : var1(1),
var2(1),
var(3),
var(4).
var1 = var+(1).
var2 = var+1(1).
var3 = var+2(1).
var4 = var+3(1).
now var1,var2,var3,var4. contains the single characters.
Regards,
Guru
mark helpful answers -
How to replace the '&' character with '&' in xi
Hi,
i need to replace the '&' character with ' &'.but i f i am converting it is displaying as '&' because internally '&' = '&'.
beacuse of this it is not converting.
is there any possiblity to change the standard conversion in xi.Graphical mapping does not support special character like & , <,> to be mapped.
You can encode & as and in UTF-8 only.
if you want the special character to be used, Opt XSLT mapping with ISO-8859-1 encoding
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="ISO-8859-1"/>
<xsl:template match="/">
<xsl:copy-of select="*" />
</xsl:template>
</xsl:stylesheet>
How to Work with Character Encodings in Process Integration (NW7.0)
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/502991a2-45d9-2910-d99f-8aba5d79fb42 -
Replace a character in a String array
I have an array of strings and am trying to replace the ' character with a space. I keep getting either a cannot be applied or cannot resolve symbol error. Can anyone help?
String arrayList = request.getParameter("field");
String newList = arrayList.replace("\'", " ");the replace method of the String class takes two parameters and both of them are characters not strings use it like this
arrayList.replace('\'', ' ');that should fix it -
Replacing the \ character in a string
I'm having trouble replacing a backslash in a string. I use .indexOf() to find the character, but I have to use an escape character and write .index("\\"), but it doesn't work - it returns -1.
Also, replace() doesn't work - gives me an java.util.regex.PatternSyntaxException. Any ideas?
thxThe escape is for the compiler, I think, and then you need to escape the backslash.
Try "\\\\".
� {� -
How to delete last character in a string
Guys i have a question...
how can i delete the last character in a string..
for example
String myString = "helloWorld, ";
how do i delete the last character in this string which is a "," ?String newString = myString.substring(0, myString.length()-1);
-
How to escape the character in a string?
I have the following code that is causing an error. I'm
attempting to use < (less than) character in a string that is
part of a dynamic query:
<cfif url.age eq 1>
<cfset askAge = " < 15">
<cfelseif url.age eq 10>
<cfset askAge = " Between 56 and 60">
<cfelseif url.age eq 11>
<cfset askAge = " > 60">
</cfif>
The error occurs as a result of the line <cfset askAge = "
< 15">. The > 60 works fine. What I need is to build the
SQL statement SELECT * FROM myTable WHERE age < 15
ColdFusion sets the string properly but when I try to run the
query I guess it thinks I'm trying to open a tag. The exact error
is:
The content beginning "< " is not legal markup. Perhaps
the " " () character should be a letter.
The content beginning "< " is not legal markup. Perhaps
the " " () character should be a letter.
I can't use the ASCII code for this character as the database
will obviously crap out.
Any help would be greatly appreciated and many thanks in
advance.
DaveDave,
What if you passed off the output of the lt/gt symbols to the
query itself?
Something like,
<cfif url.age eq 1>
<cfset compareOperator = "less"/>
<cfset askAge = "15">
<cfelseif url.age eq 10>
<cfset compareOperator = "between"/>
<cfset askAge = " 56 and 60">
<cfelseif url.age eq 11>
<cfset compareOperator = "greater"/>
<cfset askAge = "60">
</cfif>
Then in the query:
<cfquery name="qTest" datasource="dsn">
SELECT * FROM myTable
WHERE age
<cfswitch expression="#compareOperator#">
<cfcase value="less">
<
</cfcase>
<cfcase value="greater">
>
</cfcase>
<cfcase value="between">
BETWEEN
</cfcase>
<cfdefaultcase>
=
</cfdefaultcase>
</cfswitch>
#askAge#
</cfquery>
Probably a better way, at least a more efficient way, but
just a thought...cfswitch processed pretty quickly and this would
remove any issues with trying to use <> symbols.
Cheers,
Craig -
How to replace a character in a file using awk
Hello,
Does anyone has a sample script to replace a character in a file using awk?
Regards,
Edited by: slsam01 on Jul 15, 2012 12:56 PMHi
awk it's not best for this job.
For replace charecter - generaly use tr or sed
Example on awk:
awk -F<old_char> ' { for (i=1; i<NF ;i++ ) printf ( "%s<new_char>", $i ); print $NF }' <file>
#Replace "e" on "a" in /etc/hosts
awk -Fe ' { for (i=1; i<NF ;i++ ) printf ( "%sa", $i ); print $NF }' /etc/hosts
Regards.
PS. Same on *tr"
cat file | tr "e" "a" -
How to replace a character at a random position of a column in SQL Server 2000?
Hello everyone,
I'm trying to export the data of a table into a flat file. However, when I try to export it, a column which has a specific character (".") is being loaded as a new column into the file rather than the same column.
Here is the DDL/DML:
CREATE TABLE [dbo].[EXT_Name](
[A_Name] [VARCHAR](4),
[U_Name] [VARCHAR](256),
[U_Desc] [VARCHAR](256),
[Acc_Desc] [VARCHAR](256),
[S_Type] [VARCHAR](50))
Its just that's it. No more Keys and Indexes on this table.
Here is the bcp command I'm running:
EXEC [master].[dbo].[xp_cmdshell] 'bcp "SELECT * FROM [dbo].[Ext_Name]" queryout C:\Data\Ext_Name.dat -c -t, -T -S'
Data:
GEHG,/User/Personal/Project/Click.do,Search for User Project.,See Summary,Summaries
GEHG,/User/Personal/Project/Click.do,Search for User Project.Detail,null,Summaries
Instead for the data to be loaded as the above, its loading into the file as
GEHG,/User/Personal/Project/Click.do,Search for User Project.,See Summary,Summaries
GEHG,/User/Personal/Project/Click.do,Search for User Project.Detail
,null,Summaries
This issue occurs only when [Acc_Desc] column has the "." character in between the string. Could experts in this forum help me please?
Thank you,
Bangaaram
Known is a DROP, Unknown is an OCEAN.That is most likely not your problem. Your problem is most likely the source data has a CR and/or LF after it in the database.
Run this to remove them from Acc_Desc:
UPDATE [dbo].[EXT_Name]
SET [Acc_Desc] = REPLACE(REPLACE([Acc_Desc],CHAR(13),''),CHAR(10),'')
Perfect! Thank you Tom :)
Known is a DROP, Unknown is an OCEAN.
Maybe you are looking for
-
I don't understand why in Bridge there are 2 choices, -1- Open raw and -2- Open in Photoshop and yet both choices give you the same result--The raw window opens with PS below it. After having worked on my raw NEF files I save it to dng. My thinking
-
I upgraded from Iphone 3g to iphone 4. I had to update my macbook pro to Lepard just to sync. the **** thing with the new iphone 4. I bought and updated to lepard. Now when I try to sync itunes does not recognize my new iphone 4 as mine and wants to
-
Shortly after I last updated firefox, I noticed several things that were different. One, my tabs are now above the URL line. I want them under all the rows on top. I also get alerts that I can't see because when I run over it with the mouse it come d
-
List of Variables in SAP BI BEx
Dear ALL, Can any one provide me list of variables with processing type SAP EXIT I know that we can get it from Business content.But i also need some Description i.e it Pusrpose or Scenario of usage. For 0calmont,0fiscperiod.... Some docu's or pdf o
-
APP-AR-96024 when applying receipts
One of my users is getting this error when trying to apply a receipt - they are logged into 11i as Receivables Manager -> Receipt Batches -> Receipts -> Select the receipt record -> Apply. They then begin entering data and the error is produced. I sa