Finding/replacing formatting characters
I often do global replaces to re-format imported or cut/paste documents. Say, replace two paragraph marks with one, or replace 5 spaces with a tab. This is really easy in Word since you can use ^p, for example, for a paragraph mark in the Replace function. But I've hunted and hunted and can't find the equivalent in Pages. I can copy the mark in the document and paste it into the Replace window, of course, but that's several steps as opposed to one and just feels in-elegant.
Is there a code for formatting special characters?
Welcome to Apple Discussions
For most formatting characters you can use Option + the key. Or you can use the Advanced area of the Find/Replace dialog & "Insert" the chosen character from the drop-down menu. I have to use this (or copy/paste) for line breaks.
Similar Messages
-
Find/Replace nonprinting characters
Hello,
Is it possible to find and replace nonprinting characters in Pages? In particular, I want to replace all "hard" paragraph marks (i.e., return key) with newlines (shift-return), thus combining everything into the same paragraph for formatting purposes.
I can't seem to paste any of these into the F&R window. I've tried a couple of things like ^r and \r, but it's not happening. Hitting the return key, of course, confirms the find, rather than placing the character in the box.
Can anyone help? This is something I need to do fairly regularly.
TIA,
JeffHi Jeff,
Select a paragraph mark.
Menu > Edit > Find > Use Selection for Find
Menu > Edit > Find > Find...
Regards,
Ian. -
Find and Replace Japanese characters in pdf file on iPhone
Hi eveybody !
I want to find and replace Japanese characters in pdf on iPhone.
I using zlib to deflate stream - endstream block and extract text.It's work fine with latin-text.
But when i work with japanese characters , I don't know how to do it ?
I decode a sample japanese pdf file, and I know that each Japanese characters are performances as hex string : "<01b7><0e230a23>..."
But i don't know how to convert Japanese characters to the hex string like that.
Can evrybody help me?
Thanks!Searching is the same process as extracting - since it's about turning page content into something understandable. So that still remains what you need to learn/understand - of course, referring back to all the previous sections about font formats, etc.
Replacing in PDF is EXTREMELY DIFFICULT for two reasons - subset fonts and explicit glyph positioning. Have you determine (conceptually, if nothing else) how you plan to addresses these two issues?
PDF doesn't do UTF8 for page content - so don't worry about that. -
How do I 'Find & Replace' with control characters - paragraph, carriage return, tab
In Pages 4.3 (Pages '09) I could insert special characters into the Find & Replace fields. It was great. Excellent way to clean up & recover text from a pdf or html.
In Pages 5.2 that capability seems to be gone. When I turn on the special characters [Show Invisibles - shift-cmd-I], I can highlight said invisible, copy it, then paste it into the Find&Replace field. Nope. It goes in as a space, and the Find command only finds spaces. Not the invisible that I was looking for.
This was a major feature for me, folks. Much better than Word's approach. Now it is gone (I fear), and the Find & Replace is worse than Word's.
How can I recover/attain this feature?I have struggled to find this "feature" for a while.
It CANNOT be that Apple stripped out a core capability of even a basic text editor.
Apple, a reply here because this is a F%$#$%^ joke if true. -
Find/Replace Extended Character Set characters in filenames in one pipeline
Hello all,
I have to work with some very bored people. Instead of putting a dash (hex 2d) into a filename, they opt for something from this
set of extended characters, which makes my regular expressions fail. IS there a way I can efficiently find & replace anything outside the standard character set
in one pipelinewithout finding and replacing a character at a time?
So,I'd like something like:
get-childitem * | where-object $_.name -match '\x99' | rename-item -newname { $_.name -replace '\x99','='}
from hex 80 to hex FF rather than a for-each.
Thanks.Answer would depend on the way you want to replace... Easier if you want replace any char in set with selected char:
$Name = -join (180..190|%{[char]$_})
New-Item -ItemType File -Name $Name
Get-ChildItem * | Rename-Item -NewName {
[regex]::Replace(
$_.Name,
'[\xB4-\xBE]',
} -WhatIf
But if you want it more complicated, you may do that too. E.g. defining hashtable that can be used to replace individual elements:
$Replacer = @{}
foreach ($Char in (180..190 | % { [char]$_ })) {
$Replacer.Add(
[string]$Char,
(echo _, -, =, . | Get-Random)
$Replacer
Get-ChildItem * | Rename-Item -NewName {
[regex]::Replace(
$_.Name,
'[\xB4-\xBE]',
$Replacer[$args[0].Value]
} -WhatIf
Using this syntax make it possible to include some logic in replace. E.g. you could easily use switch to decide what to do with given string:
Get-ChildItem * | Rename-Item -NewName {
[regex]::Replace(
$_.Name,
'[\xB4-\xBE]',
switch ($args[0].Value) {
º { "0" }
µ { "u" }
¹ { "1" }
¸ { "," }
Default { "_" }
} -WhatIf -
Pages 5: Find and replace special characters
Has this feature gone? Or can anyone tell me where to find it? I neeed, for example, to replace double paragraph breaks with single ones, how can I do this?
I can't find it either, but the following appears to work:
Turn on Show Invisibles in the View menu.
Select (highlight) the double para breaks.
Use Command-E (Find using selected text).
Open the Find dialogue box (Command-F) and select Find & Replace.The selected para breaks will be in the Find text entry box, but will not be visible!
Click in the Replace text entry box.
Select (highlight) a single para break.
Go to the Edit menu / Find and select 'Use selection for replace' (it will not show in the Replace entry box).
In the Find & Replace dialogue box, click on the Forward or Back arrows to highlight the selected items (e.g. double para break) where you wish to start replacing in the document.
Use the Replace All / Replace & Find / Replace buttons as per usual.
Not a nice solution, but I hope it gets you going until Apple restores the previous functionality! -
Find Replace from Textfile with regex
Hello.
I'm wondering if anyone knows about an existing script that does a find/replace by list like the script "FindChangeByList.jsx" that comes with every InDesign installation.
This consists of tow parts, the script itself with the functionality and a simple textfile where you have simple one-liners capable of find/replace with regex.
the Textfile:
//FindChangeList.txt
//A support file for the InDesign CS4 JavaScript FindChangeByList.jsx
//This data file is tab-delimited, with carriage returns separating records.
//The format of each record in the file is:
//findType<tab>findProperties<tab>changeProperties<tab>findChangeOptions<tab>description
//Where:
//<tab> is a tab character
//findType is "text", "grep", or "glyph" (this sets the type of find/change operation to use).
//findProperties is a properties record (as text) of the find preferences.
//changeProperties is a properties record (as text) of the change preferences.
//findChangeOptions is a properties record (as text) of the find/change options.
//description is a description of the find/change operation
//Very simple example:
//text {findWhat:"--"} {changeTo:"^_"} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false} Find all double dashes and replace with an em dash.
//More complex example:
//text {findWhat:"^9^9.^9^9"} {appliedCharacterStyle:"price"} {include footnotes:true, include master pages:true, include hidden layers:true, whole word:false} Find $10.00 to $99.99 and apply the character style "price".
//All InDesign search metacharacters are allowed in the "findWhat" and "changeTo" properties for findTextPreferences and changeTextPreferences.
//If you enter backslashes in the findWhat property of the findGrepPreferences object, they must be "escaped"
//as shown in the example below:
//{findWhat:"\\s+"}
grep {findWhat:" +"} {changeTo:" "} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false} Find all double spaces and replace with single spaces.
grep {findWhat:"\r "} {changeTo:"\r"} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false} Find all returns followed by a space And replace with single returns.
grep {findWhat:" \r"} {changeTo:"\r"} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false} Find all returns followed by a space and replace with single returns.
grep {findWhat:"\t\t+"} {changeTo:"\t"} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false} Find all double tab characters and replace with single tab characters.
grep {findWhat:"\r\t"} {changeTo:"\r"} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false} Find all returns followed by a tab character and replace with single returns.
grep {findWhat:"\t\r"} {changeTo:"\r"} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false} Find all returns followed by a tab character and replace with single returns.
grep {findWhat:"\r\r+"} {changeTo:"\r"} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false} Find all double returns and replace with single returns.
text {findWhat:" - "} {changeTo:"^="} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false} Find all space-dash-space and replace with an en dash.
text {findWhat:"--"} {changeTo:"^_"} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false} Find all dash-dash and replace with an em dash.
The script:
//FindChangeByList.jsx
//An InDesign CS5.5 JavaScript
@@@BUILDINFO@@@ "FindChangeByList.jsx" 3.0.0 15 December 2009
//Loads a series of tab-delimited strings from a text file, then performs a series
//of find/change operations based on the strings read from the file.
//The data file is tab-delimited, with carriage returns separating records.
//The format of each record in the file is:
//findType<tab>findProperties<tab>changeProperties<tab>findChangeOptions<tab>description
//Where:
//<tab> is a tab character
//findType is "text", "grep", or "glyph" (this sets the type of find/change operation to use).
//findProperties is a properties record (as text) of the find preferences.
//changeProperties is a properties record (as text) of the change preferences.
//findChangeOptions is a properties record (as text) of the find/change options.
//description is a description of the find/change operation
//Very simple example:
//text {findWhat:"--"} {changeTo:"^_"} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false} Find all double dashes and replace with an em dash.
//More complex example:
//text {findWhat:"^9^9.^9^9"} {appliedCharacterStyle:"price"} {include footnotes:true, include master pages:true, include hidden layers:true, whole word:false} Find $10.00 to $99.99 and apply the character style "price".
//All InDesign search metacharacters are allowed in the "findWhat" and "changeTo" properties for findTextPreferences and changeTextPreferences.
//If you enter backslashes in the findWhat property of the findGrepPreferences object, they must be "escaped"
//as shown in the example below:
//{findWhat:"\\s+"}
//For more on InDesign scripting, go to http://www.adobe.com/products/indesign/scripting/index.html
//or visit the InDesign Scripting User to User forum at http://www.adobeforums.com
main();
function main(){
var myObject;
//Make certain that user interaction (display of dialogs, etc.) is turned on.
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
if(app.documents.length > 0){
if(app.selection.length > 0){
switch(app.selection[0].constructor.name){
case "InsertionPoint":
case "Character":
case "Word":
case "TextStyleRange":
case "Line":
case "Paragraph":
case "TextColumn":
case "Text":
case "Cell":
case "Column":
case "Row":
case "Table":
myDisplayDialog();
break;
default:
//Something was selected, but it wasn't a text object, so search the document.
myFindChangeByList(app.documents.item(0));
else{
//Nothing was selected, so simply search the document.
myFindChangeByList(app.documents.item(0));
else{
alert("No documents are open. Please open a document and try again.");
function myDisplayDialog(){
var myObject;
var myDialog = app.dialogs.add({name:"FindChangeByList"});
with(myDialog.dialogColumns.add()){
with(dialogRows.add()){
with(dialogColumns.add()){
staticTexts.add({staticLabel:"Search Range:"});
var myRangeButtons = radiobuttonGroups.add();
with(myRangeButtons){
radiobuttonControls.add({staticLabel:"Document", checkedState:true});
radiobuttonControls.add({staticLabel:"Selected Story"});
if(app.selection[0].contents != ""){
radiobuttonControls.add({staticLabel:"Selection", checkedState:true});
var myResult = myDialog.show();
if(myResult == true){
switch(myRangeButtons.selectedButton){
case 0:
myObject = app.documents.item(0);
break;
case 1:
myObject = app.selection[0].parentStory;
break;
case 2:
myObject = app.selection[0];
break;
myDialog.destroy();
myFindChangeByList(myObject);
else{
myDialog.destroy();
function myFindChangeByList(myObject){
var myScriptFileName, myFindChangeFile, myFindChangeFileName, myScriptFile, myResult;
var myFindChangeArray, myFindPreferences, myChangePreferences, myFindLimit, myStory;
var myStartCharacter, myEndCharacter;
var myFindChangeFile = myFindFile("/FindChangeSupport/FindChangeList.txt")
if(myFindChangeFile != null){
myFindChangeFile = File(myFindChangeFile);
var myResult = myFindChangeFile.open("r", undefined, undefined);
if(myResult == true){
//Loop through the find/change operations.
do{
myLine = myFindChangeFile.readln();
//Ignore comment lines and blank lines.
if((myLine.substring(0,4)=="text")||(myLine.substring(0,4)=="grep")|| (myLine.substring(0,5)=="glyph")){
myFindChangeArray = myLine.split("\t");
//The first field in the line is the findType string.
myFindType = myFindChangeArray[0];
//The second field in the line is the FindPreferences string.
myFindPreferences = myFindChangeArray[1];
//The second field in the line is the ChangePreferences string.
myChangePreferences = myFindChangeArray[2];
//The fourth field is the range--used only by text find/change.
myFindChangeOptions = myFindChangeArray[3];
switch(myFindType){
case "text":
myFindText(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions);
break;
case "grep":
myFindGrep(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions);
break;
case "glyph":
myFindGlyph(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions);
break;
} while(myFindChangeFile.eof == false);
myFindChangeFile.close();
function myFindText(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions){
//Reset the find/change preferences before each search.
app.changeTextPreferences = NothingEnum.nothing;
app.findTextPreferences = NothingEnum.nothing;
var myString = "app.findTextPreferences.properties = "+ myFindPreferences + ";";
myString += "app.changeTextPreferences.properties = " + myChangePreferences + ";";
myString += "app.findChangeTextOptions.properties = " + myFindChangeOptions + ";";
app.doScript(myString, ScriptLanguage.javascript);
myFoundItems = myObject.changeText();
//Reset the find/change preferences after each search.
app.changeTextPreferences = NothingEnum.nothing;
app.findTextPreferences = NothingEnum.nothing;
function myFindGrep(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions){
//Reset the find/change grep preferences before each search.
app.changeGrepPreferences = NothingEnum.nothing;
app.findGrepPreferences = NothingEnum.nothing;
var myString = "app.findGrepPreferences.properties = "+ myFindPreferences + ";";
myString += "app.changeGrepPreferences.properties = " + myChangePreferences + ";";
myString += "app.findChangeGrepOptions.properties = " + myFindChangeOptions + ";";
app.doScript(myString, ScriptLanguage.javascript);
var myFoundItems = myObject.changeGrep();
//Reset the find/change grep preferences after each search.
app.changeGrepPreferences = NothingEnum.nothing;
app.findGrepPreferences = NothingEnum.nothing;
function myFindGlyph(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions){
//Reset the find/change glyph preferences before each search.
app.changeGlyphPreferences = NothingEnum.nothing;
app.findGlyphPreferences = NothingEnum.nothing;
var myString = "app.findGlyphPreferences.properties = "+ myFindPreferences + ";";
myString += "app.changeGlyphPreferences.properties = " + myChangePreferences + ";";
myString += "app.findChangeGlyphOptions.properties = " + myFindChangeOptions + ";";
app.doScript(myString, ScriptLanguage.javascript);
var myFoundItems = myObject.changeGlyph();
//Reset the find/change glyph preferences after each search.
app.changeGlyphPreferences = NothingEnum.nothing;
app.findGlyphPreferences = NothingEnum.nothing;
function myFindFile(myFilePath){
var myScriptFile = myGetScriptPath();
var myScriptFile = File(myScriptFile);
var myScriptFolder = myScriptFile.path;
myFilePath = myScriptFolder + myFilePath;
if(File(myFilePath).exists == false){
//Display a dialog.
myFilePath = File.openDialog("Choose the file containing your find/change list");
return myFilePath;
function myGetScriptPath(){
try{
myFile = app.activeScript;
catch(myError){
myFile = myError.fileName;
return myFile;
This is a very useful and easy to maintain script which even people who cant write scripts (but know how to use regex) can do complex search replace mass replacements.
Would love to find something like this for FrameMaker 12 (as i can't write scripts myself).
regards
danielI have visited that site. The first item in the external link says: "You can also configure Firefox to automatically search for text when you type any characters outside of a text field. When typing in a text field these characters should show up in the text field and not trigger the Quick Find bar. "
What I am looking for is the exact opposite. Once my first search is entered in the text box, and the info comes back, I want to start typing the next symbol, and have it automatically show up in the text box, not the Quick Find box. That is how it was working up until a couple of months ago. -
TextEdit - Save preset for Find & Replace?
Hey, all!
Quick question... is there any way to save a preset for a Find & Replace function in the native TextEdit app in Mac OS? I do a routine F&R using a long "Insert Pattern" (I haven't had time to learn Regular Expressions yet in order to use another app)... I'd love to be able to just do a quick F&R on a text file instead of having to build the string every time.
Possible?
Thanks!
-=R=-thnx Tom - yes, all the text is there, editable and I can add new text to it and save. But I can't search it using Find, trying unique words I see right there in the first few paragraphs atop the file. Then tried 'and' which only found two in the whole large file, embedded within a block of what I guess are formatting characters also bunched up at the bottom of the file below my original text.
Oops, I just realized now that this file is not actually an RTF, its a Word 97 .doc -- which either means I converted it at some point in TextEdit, or its the original .doc file I started long ago with my ancient Microsoft Word that I used before going to Mavericks (was able to use Word in Snow Leopard but is no longer supported in Mavericks, I think its referred to as a 'PowerPC' application.)
What should I do? Would converting it to an RTF file help, if so how do I do that?
thanks!
Randy -
1. I'm trying to replace non-printing formatting characters (carriage return, line feed, tab, whatever) in a document with something else or, variously, replace existing text with a carriage return. I remember having a handy little cheat sheet made up with the substitutions for those characters for use in the Edit > Find windows, but it seems to have gone walkabout.
2. Have pored through various Help files and other sources and, if there, I've just missed it over and over again. Can someone please point me to the right spot or, even better, just dump out what those special little codes are?
3. TIA for any inputs or assistance.Hi, Michael.
Depending on the type of document you are working upon, you might want to try the shareware application Tex-Edit Plus. This little wonder is my text editor of choice and is ideally suited to that kind of Find/Replace work. It also has a little button in the lower-left border labeled [A] that will show a table of ASCII character codes.
You can try Tex-Edit for free.
Apple's TextEdit does not even have a way of showing the non-printing characters.
Good luck!
Dr. Smoke
Author: Troubleshooting Mac® OS X -
Batch code for running a find/replace all on multiple files within a source floder/directory
What I need is a Batch source code that will open all files in a folder/directory and run a find and replace_all query within them and then save all the files. The files were created in Illustrator and saved using the Scene7 FXG format extension. These files will be uploaded into Scene7 as a group after the find and replace macro/query is run on the code. The same find and replace query will be the same for all the files. Basically this function or batch process will save time in setting the same parameters all at one time instead of having to set the parameters individually in scene7.
a source code sample of the find/replace module macro might be searchString: s7:colorvalue="#FFFFFFFF"
replaceString: s7:colorValue="#&txtclr;"
searchWhat "FXG document"
searchSource: true,
useRegularExpressions: true
I have no problems creating batch files within Ai and PhotoShop but I have limited programming skills in how to create source code for manuipulating documents outside of those apps or in a OS invironment.
I could probably come up witha simple program to do what i want for one document but i get lost when dealing with multiple documents in a source folder (prolbem is, I will be dealing with thousands of documents not 100 or less)
If anything which Adope cloud app would work best: Dreamweaver or Edge code (or just use my notepad)What I need is a Batch source code that will open all files in a folder/directory and run a find and replace_all query within them and then save all the files. The files were created in Illustrator and saved using the Scene7 FXG format extension. These files will be uploaded into Scene7 as a group after the find and replace macro/query is run on the code. The same find and replace query will be the same for all the files. Basically this function or batch process will save time in setting the same parameters all at one time instead of having to set the parameters individually in scene7.
a source code sample of the find/replace module macro might be searchString: s7:colorvalue="#FFFFFFFF"
replaceString: s7:colorValue="#&txtclr;"
searchWhat "FXG document"
searchSource: true,
useRegularExpressions: true
I have no problems creating batch files within Ai and PhotoShop but I have limited programming skills in how to create source code for manuipulating documents outside of those apps or in a OS invironment.
I could probably come up witha simple program to do what i want for one document but i get lost when dealing with multiple documents in a source folder (prolbem is, I will be dealing with thousands of documents not 100 or less)
If anything which Adope cloud app would work best: Dreamweaver or Edge code (or just use my notepad) -
Find & Replace text in html files
This is my first real attempt at using Automator, and it has become increasingly frustrating for me. I love the idea of Automator, nice interface, and it appears to be so easy to use. But, I can't get it to actually DO anything and I don't understand why.
Here is my goal:
to batch process multiple html files to remove certain characters and words (or replace them with empty space).
I currently open these files in Pages and do 6 separate Find & Replace commands for each file before I continue with my other processing tasks. This is very tedious and I believe the computer should be able to find & replace multiple items at one time. (I have used other utilities to do batch renaming and trimming file names before.)
All I want to do is select a group of files (usually 25 at a time) and have Automator get rid of all the unwanted words and characters before I open each file for final processing in Pages. I found a set of Automator actions for TextEdit which includes a Find & Replace action, but I've wasted over an hour so far trying to get it to work.
When I run the workflow, it acts like it's doing something, but the files remain unchanged. I have tried using actions such as Read Text File, Get Contents of TextEdit Document, Set Contents of TextEdit Document, along with 6 instances of Find & Replace, but I cannot get it to work.
I'm at a point today where I cannot afford to mess around with this anymore. I have to do it the long way in Pages or else I'll never get it done, but I want to get these Automator workflows to work before I have to repeat this task. (I do this at least once a week right now.)
Any ideas or suggestions? I've tried reading in the help menus and support pages, but perhaps I'm just not understanding something here.Any ideas or suggestions?
You might be interested in using TextWrangler. It can perform batch find-and-replace changes across multiple selected files.
Good luck!
Andrew99 -
Find/Replace - multiple replace ... maybe with regex
Hello Dreamweaver community ... I'm relatively new to using Dreamweaver as an editor and I'm working on a large migration project that I'm trying to make easier. Basically, I'm converting an entire site from English to Spanish ... almost literally tag by tag
Something that would make my job a lot easier is if ... every time I open a new Spanish language content file I could ...
replace ALL Spanish language grammar symbols, accents, tildes etc ... with their HTML equivalents ... for example ...
á = á
é = é
í = í
And so on ... there's about 10-12 major changes ...
What I need to figure out is how to save a find/replace query in Dreamweaver .dwr format that replaces all symbols at once instead of needing to do them one at a time ...
Seems like this shoudl be possible but I haven't figured out the right syntax ... I used the (.+) and $1 but it only worked conditionally - in the order the replacements were written. I need it to find ALL instances of a spanish symbol and replace it with its corresponding html ...
Can anyone help me with this ...?
Thank you in advance ...This is in fact the only solution I found to this problem.
Creating an extension is not that difficult once you have the right
reference material.
Have a look at:
DW API function to find and replace
http://livedocs.adobe.com/en_US/Dreamweaver/9.0_API/dwr_code_cd_013.html
Sample extension file on your machine after installing DW
C:\Program Files\Adobe\Adobe Extension
Manager\Samples\Dreamweaver\
Full specifications of the MXI (extension file) format
http://download.macromedia.com/pub/exchange/mxi_file_format.pdf
quote:
Originally posted by:
Newsgroup User
> So, is it indeed possible to run more than one
find/replace query at a
> time?
As far as i know, no it's not possible.
There has been mentions in the past to this question that a
series of
find/replace queries could be built as a dw extension instead
of a saved
search query.
Alan
Adobe Community Expert, dreamweaver -
How to replace special characters in string.
Hello,
I want to replace special characters such as , or ; with any other character or " ".I find out there is no such function is java for this.There is only replace() but it accepts only chars.If anybody know how to do this?.
Thanks,Hello,
I want to replace special characters such as , or ;
with any other character or " ".I find out there is no
such function is java for this.There is only replace()
but it accepts only chars.If anybody know how to do
this?.
Thanks,Can't you just do the following?
public class Test
public static void main(String[] args)
String testString = "Hi, there?";
System.out.println(testString.replace(',',' '));
} -
Using Grep to find/replace
I'm trying to find out how to use GREP in find/replace to chage the formatting of some text that comes in from a spreadsheet.
I worked out the GREP query "~b(\d\d)~b", which finds a paragraph return, followed by two digits, followed by another paragraph return
and then it is replaced by "\t $1~b", which is a tab, the two found digits and a para return.
What i need to do is to amend the query to find ANY number of digits, (which may be comma delimited: eg 23, 36, 48 ,50), and then replace with a tab + found text.
I suppose what I'm looking for is a way for the query to find "any text between two paragraph returns, no matter what tthe length", but I don't know how to do this.All the Wildcard options seem to find just one exampler (one digit, one character etc)And you came so far
The operators for repeat are ? (zero or once), * (zero or more) and + (once or more). You can also specify exact numbers: {at least,up to}.
All of these operators are "greedy" by default -- they will match as much as possible. To match as least as possible (which I'm sure you'll come up against, sooner or later), add another ? after the repeat expression.
So this will find one digit, then optionally another (which will always be included):
\d\d?
and this one digit, then zero or as much as ten million million zillion:
\d\d*
which is functionally the same as
\d+
And this will find between 3 and 8 digits but will forced to use the shortest possible match:
\d{3,8}?
That said: A quick & dirty solution for your actual problem is to find any amount of digits, spaces, and comma's:
~b[\d, ]+~b
(we need the plus here because otherwise it would also match an empty line). The [..] brackets an Inclusive list --- it will match any of the single codes inside.
A more complicated but 'neater' way is to search very specifically only for number, comma, space, number sequences -- it's neater because that way malformed lines (comma without a space) will be skipped!
(It also introduces another code -- the parentheses operators. Look them up in a good GREP reference --lost of people are enthousiastic about Peter Kahrel's O'Reilly title, because it's about using GREP in InDesign.)
~b\d+(, \d+)*~b -
Looking for, and replace special characters
Hi
I am quite new to AppleScript and can't figure this out. Any help would be appreciated.
I have received several (a lot of) folders containing images with some strange characters in the file names. The images has to go to web, and I want to replace those characters with some that are web friendly. The characters in question is some Swedish A's and O's (Ä, ä, Ö, ö) and one that looks like the Apple Command symbol. (I was told this one is a combination of a and e).
Then, I would like to replace all spaces between the words in the file names with an underscore.
In addition, all image file names start with capitals and I would like to replace these as well.
Thanks
Neal
G5 Mac OS X (10.4.6)Here's a modified version of the standard script:
try
tell application "Finder" to set the source_folder to (folder of the front window) as alias
on error -- no open folder windows
set the source_folder to path to desktop folder as alias
end try
display dialog "Search and replace in:" buttons {"File Names", "Folder Names", "Both"} default button 3
set the search_parameter to the button returned of the result
repeat
display dialog "Enter text to find in the item names:" default answer "" buttons {"Cancel", "OK"} default button 2
set the search_string to the text returned of the result
if the search_string is not "" then exit repeat
end repeat
repeat
display dialog "Enter replacement text:" default answer "" buttons {"Cancel", "OK"} default button 2
set the replacement_string to the text returned of the result
if the replacement_string contains ":" then
beep
display dialog "A file or folder name cannot contain a colon (:)." buttons {"Cancel", "OK"} default button 2
else if the replacement_string contains "/" then
beep
display dialog "A file or folder name cannot contain a forward slash (/)." buttons {"Cancel", "OK"} default button 2
else
exit repeat
end if
end repeat
display dialog "Replace “" & the search_string & "” with “" & the replacement_string & "” in every item name?" buttons {"Cancel", "OK"} default button 2
tell application "Finder"
set the item_list to every item of entire contents of source_folder
tell me
set item_list to reverse of the item_list
end tell
set source_folder to source_folder as string
repeat with i from 1 to number of items in the item_list
set the_name to name of item i of the item_list
set this_item to item i of the item_list
set this_info to properties of this_item
set the current_name to the_name
set change_flag to false
repeat with this_char from 1 to (count items of search_string)
if the current_name contains item this_char of (search_string) then
if the search_parameter is "Folder Names" and ¬
folder of this_info is true then
set the change_flag to true
else if the search_parameter is "File Names" and ¬
folder of this_info is false then
set the change_flag to true
else if the search_parameter is "Both" then
set the change_flag to true
end if
if the change_flag is true then
set this_item to item i of the item_list
-- replace target string using delimiters
set AppleScript's text item delimiters to the item this_char of search_string
set the textitemlist to every text item of the current_name
set AppleScript's text item delimiters to the item this_char of replacement_string
set the newitemname to the textitemlist as string
set AppleScript's text item delimiters to ""
set the current_name to newitemname
end if
end if
end repeat
my setitem_name(thisitem, current_name)
end repeat
end tell
beep 2
on setitem_name(thisitem, newitemname)
tell application "Finder"
--activate
set the parentcontainerpath to (get the container of this_item) as text
if not (exists item (the parentcontainerpath & newitemname)) then
try
set the name of this_item to newitemname
return this_item
on error the error_message number the error_number
if the error_number is -59 then
set the error_message to "This name contains improper characters, such as a colon (:)."
else --the suggested name is too long
set the error_message to error_message -- "The name is more than 31 characters long."
end if
--beep
tell me to display dialog the error_message default answer newitemname buttons {"Cancel", "Skip", "OK"} default button 3
copy the result as list to {newitemname, button_pressed}
if the button_pressed is "Skip" then return 0
my setitem_name(thisitem, newitemname)
end try
else --the name already exists
--beep
tell me to display dialog "This name is already taken, please rename." default answer newitemname buttons {"Cancel", "Skip", "OK"} default button 3
copy the result as list to {newitemname, button_pressed}
if the button_pressed is "Skip" then return 0
my setitem_name(thisitem, newitemname)
end if
end tell
end setitemname
This script variant works by accepting a source string in the form "AB" and desired string "CD". When run, ABCA will become CDCC with the sample strings.
(19254)
Maybe you are looking for
-
Formatting DATEs with FORMAT clause and not with "to_date()" ?
Well I know I could format a DATE inline with the to_date() function. But is there a way to format it in a separate FORMAT clause similar to numbers? If yes how would a format of dd.mm.yyyy or yyyy.mm.dd hh:mm:ss look like?
-
I discovered that the e-mail appilcation we are using (Thunderbird) has errors with timezones. For example: In my calendar, I created 3 events (with these names: Budapest, Kiev, Monaco) Then I set the Budapest event the Budapest (+1) timezone, for th
-
Mixed up messages in conversation view on C3-01
Has anyone else noticed that from time to time the text messages when viewed in a converstaion format (chat listing for each sender's name) can get mixed up? So one user's latest text is showed in the conversation of a text message conversation with
-
Inserting Chinese character using sqlplus
I am not able to insert Chinese character using sqlplus . Am getting disconnected when trying to insert. with no error message coming is disconnected form oracle enterpise 10.2.0.2.0 with .. mining.. Please help.
-
CS6: how to update 12.0 to 12.2? [was: cs6 1200 updates]
Hello I have cs6 Version 12.0 build 5861 I understand there is a later version 12.2 Build 6006. According to Help Updates the applications are all up to date. Can anyone say how I can get the latest updates please? Thank you John