Search Replace within a text
//Create Method named ReplaceBlankWithDash(input string, input/output
OutputTextData):Boolean
InputTextData : TextData = new;
OutputTextData : TextData = new;
Success : Boolean = True;
InputTextData.SetValue(string);
while not (InputTextData.IsAtEnd()) do
if InputTextData.IsAlpha() or InputTextData.IsDigit() then
OutputTextData.Concat(InputTextData.CopyRange(InputTextData.Offset,InputText
Data.Offset+1));
else
//space
OutputTextData.Concat('-'); //your char here ...you could
just add another variable passed in and use its value
end if;
InputTextData.MoveNext();
end while;
Success = (OutputTextData.ActualSize > 0);
return (Success);
Regards,
Dave Campbell
Consultant,
Caro Systems Inc.
Mailto:Dave.CampbellCaroSys.com
Although some applications such as BBEdit provide a search and replace action, there isn't a default action to do that. You can use a Run AppleScript action to search and replace in the input text, if you are wanting to stay within Automator. You can also use TextWrangler (free) - it will search and replace across multiple documents.
Similar Messages
-
In the textedit version on Snow leopard it was possible to search and replace within a peice of selected text only i.e. not the entire file. This was a very useful feature because you could select a paragraph and replace all occurences of word1 with word2 within that paragraph only! This feature appears to be missing from the mountain lion version of textedit (version 1.8). Or can anyone tell me how to do it ... ?
Having 46 people view a post without replying is not unusual. Some people look at a question to see if it's something they'd like to know the answer to, and then come back when it has eventually been answered.
I'm not sure if you need to escape forward slashes in Dreamweaver's Find and Replace dialog box, but I normally do because both JavaScript and PHP normally use forward slashes as delimiters to mark the beginning and end of the regex like this:
var pattern = /[A-Z]{4}/; // JavaScript
$pattern = '/[A-Z]{4}/'; // PHP
When a forward slash appears inside the regex, you need to escape it with a backslash to avoid confusion with the closing delimiter.
As you have worked out, a capturing group is created by wrapping part of the regex in parentheses.
If you want to match exactly 38 characters, you can use [\S\s]{38}. That includes spaces, newline characters, symbols, everything.
If you're trying to find everything between two tags, you can do this:
(<\/tag_name>)([^<]+)
The closing tag is captured as $1 and everything up to the next opening tag is captured as $2.
Learning regular expressions is not easy. I don't claim to be an expert, but I enjoy the challenge of trying to solve them. If you're interested in regular expressions, there are several books published by O'Reilly. "Mastering Regular Expressions" is the ultimate authority, but it's a difficult read (not because it's badly written, but because of the complexity of the subject). "Regular Expressions Cookbook" is very good. There's also a new "Introducing Regular Expressions", but I haven't read it. -
DW CS5 Search & Replace within a Found Set
Can't get this to work in CS5. The actions below used to work in previous DW:
Action → Search and Replace
See 100 found results using Find All
Objective: to replace 50 of those results and leave the other 50 as is
Action that used to work ↓
With the 100 results showing, click on green arrow again to bring up the Find dialong again. In the found documents list, use the Control key to pick out the documents to replace, return to the Find dialog and select Replace.
That used to work to automatically replace the selected documents.
Is anyone familiar with this?I just tried this in Dreamweaver CS3 (Version 9.0) and it does not work as you describe Dreamweaver CS4's capabilities. Instead, it replaces all instead of selected.
I think that the only way to get Dreamweaver to do a search and replace like that is to do your search, then, in the file viewer, do a replace for selected only—and not in the found documents list.
I realize this is a workaround that is not the same function but it does work. -
Search Results Are Highlighted Within The Text Box? How ? Access 2013
Hi Every one ,
Below I am describing some coding issue in VBA-MS Access I am facing right now , and I hope u guys could help me resolve the issues :
DB : MS access 2013 - RichTextBox In A Form -
Language : VBA
Problem In short : struggling to highlighting user search word within the search result query ..
What I want :
Helping to fix the second code shown below , the one I used to highlight ( reformat ) the text who's bound to a a field that store memo data type . code
My Result Search Query VBA COde ( Work perfectly )
strWhereToSearch = IIf(.framSearchIn.Value = 1, "[quknotSubject]", "[quknotBody] ")
strCondition = strWhereToSearch & " Like '* " & strTextSearch & " *' OR " & _
strWhereToSearch & " Like '" & strTextSearch & " *' OR " & _
strWhereToSearch & "Like '* " & strTextSearch & "'"
strSql = " Select * from qryExtraTool_QuickNoteSubCatMainCat "
strSql = strSql & " WHERE " & strCondition & " ORDER BY quknotDate"
The code that i am struggling to make it work for me to highlight the search word inside the textbox called .txtQuickNoteBody :
'Control Source for the text box to display matches.
Const strcTagStart = "<font color=""""red"""">"
Const strcTagEnd = "</font>"
strControlSource = "=IIf(" & strField & " Is Null, Null, " & _
"Replace(" & strField & ", """ & strSearchValue & """, """ & _
strcTagStart & strSearchValue & strcTagEnd & """))
.txtQuickNoteBody.ControlSource = strControlSource
Thank u all in advance .Thank u so Bruce , I finally found an answer to my question.
The solution u provided looks complete except that i am confused by the meaning of strField , may i didnt provide more details in my post .
The strField var i provided earlier was not meant to be placed in my code , the correct one is shown below .However , the strField means according to me is the field against which the search operation should take place based on the ( search Term )
the user provided .
Here is the code after applying the solution u suggested :
'Information collected from the user
strWhereToSearch = IIf(.framSearchIn.Value = 1, "[quknotSubject]", "[quknotBody] ")
strCondition = strWhereToSearch & " Like '* " & strTextSearch & " *' OR " & _
strWhereToSearch & " Like '" & strTextSearch & " *' OR " & _
strWhereToSearch & "Like '* " & strTextSearch & "'"
'Fill result search Recordset
strSql = " Select * from qryExtraTool_QuickNoteSubCatMainCat "
strSql = strSql & " WHERE " & strCondition & " ORDER BY quknotDate"
'Control Source for the text box to display matches. ( Highlight the search word )
txtQuickNoteBody = SearchHilight(strWhereToSearch, strTextSearch)
Tell me if my implementation to your code is right ?
Thank u again Bruce ... -
Search & replace text programmatically in pdf file
I need to search & replace text programmatically (preferably in .NET c#) in existing pdf file.
Does anyone know how to do it (maybe with with Acrobat SDK) ?
Thanks in advance!
A.
PS: Well done working example :-)Searching APIs are provided, but there no APIs for replacing since that's not a standard operation on a PDF (given the rendering model).
-
RE: (forte-users) search and replace within aTextData
Welll, you're both right. The MoveToChar makes it unnecessary (if a little
sloppy) to MoveNext as long as you've changed the character. thus,
outStr: TextData = new;
outStr.SetValue(inStr);
while (outStr.MoveToChar(' ')) do
outStr.ReplaceRange('_', outStr.Offset, outStr.Offset+1);
end while;
return outStr;
works fine to change blanks to underscores.
Regards,
David
-----Original Message-----
From: Campbell, Dave [mailto:DCampbellpurolator.com]
Sent: Friday, 14 January 2000 0:58
To: 'Matthew Middleton'
Cc: kamranaminyahoo.com
Subject: RE: (forte-users) search and replace within a TextData
If you do not use the MoveNext method to skip beyond the "found" character,
a subsequent invocation of MoveToChar will find the same character, located
at exactly the same offset.
If there is no match, MoveToChar returns FALSE and the current offset does
not change.
----- Original Message -----
From: Matthew Middleton <mathew.middletonlawpoint.com.au>
To:kamranaminyahoo.com
Unless I'm missing something here...you needn't go through every
character...use MoveToChar()...as per Help...
while (TextdataObj.MoveToChar (' ')) do
end while;
Regards,
Dave Campbell
Consultant,
Caro Systems Inc.
Mailto:Dave.CampbellCaroSys.com
For the archives, go to: http://lists.sageit.com/forte-users and use
the login: forte and the password: archive. To unsubscribe, send in a new
email the word: 'Unsubscribe' to: forte-users-requestlists.sageit.comWhy not this:
while myText.moveToString(' ') do
myText.ReplaceRange('-', myText.Offset, myText.Offset+1);
end while;
or if you prefer verbosity:
while myText.moveToString(source=' ') do
myText.ReplaceRange(source='-', startOffset=myText.Offset,
endOffset=myText.Offset+1);
end while;
-----Original Message-----
From: FatchJeBAM.com [mailto:FatchJeBAM.com]
Sent: Wednesday, January 12, 2000 2:51 PM
To: Troy.Burnsvacationclub.com; kamranaminyahoo.com
Subject: RE: (forte-users) search and replace within a TextData
How about this?? May have to play with start/end on ReplaceRange as I
didn't really test this
Anybody got a better way??
-- replace space with underscore
For x in 1 to myTextdata.LengthToEnd() do
If myTextData.IsSpace() then
MyTextdata.ReplaceRange('_'. Startoffset=myTextdata.offset,
endoffset=myTextdata.offset+1);
End if;
MyTextdata.MoveNext;
End for;
Jerry Fatcheric
-----Original Message-----
From: Burns, Troy [mailto:Troy.Burnsvacationclub.com]
Sent: Wednesday, January 12, 2000 9:40 AM
To: kamranaminyahoo.com
Subject: (forte-users) search and replace within a
TextData
Hello all,
I need to search within a textdata object, replacing all
occurrances of a
space
with another character. Can you give a quick code example
of how I would do
this?
Thanks in advance,
Troy
Troy Burns
Marriott Vacation Club Intl.
E-mail: troy.burnsvacationclub.com
Phone: (941) 688-7700 ext. 4408
For the archives, go to: http://lists.sageit.com/forte-users
and use
the login: forte and the password: archive. To unsubscribe,
send in a new
email the word: 'Unsubscribe' to:
forte-users-requestlists.sageit.com
For the archives, go to: http://lists.sageit.com/forte-users and use
the login: forte and the password: archive. To unsubscribe, send in a new
email the word: 'Unsubscribe' to: forte-users-requestlists.sageit.com -
Search for a space within a text field
Hi All
I am trying to search for a sapce within a text field but sofar not being very successful. I have used:
FIND search_str
IN text_str
MATCH COUNT lv_mcnt
MATCH OFFSET lv_moff.
where search_str = TYPE c VALUE ' '.
I am looking a way of searching a character within the string using ABAP (like INSTRING in other languages). If you have similiar codes - Could you please post me a copy - ThanksHI
Check this..
DATA string7(30) TYPE c VALUE 'This is a little sentence.'.
WRITE: / 'Searched', 'SY-SUBRC', 'SY-FDPOS'.
ULINE /1(26).
SEARCH string7 FOR 'X'.
WRITE: / 'X', sy-subrc UNDER 'SY-SUBRC',
sy-fdpos UNDER 'SY-FDPOS'.
SEARCH string7 FOR 'itt '.
WRITE: / 'itt ', sy-subrc UNDER 'SY-SUBRC',
sy-fdpos UNDER 'SY-FDPOS'.
SEARCH string7 FOR '.e .'.
WRITE: / '.e .', sy-subrc UNDER 'SY-SUBRC',
sy-fdpos UNDER 'SY-FDPOS'.
SEARCH string7 FOR '*e'.
WRITE: / '*e ', sy-subrc UNDER 'SY-SUBRC',
sy-fdpos UNDER 'SY-FDPOS'.
SEARCH string7 FOR 's*'.
WRITE: / 's* ', sy-subrc UNDER 'SY-SUBRC',
sy-fdpos UNDER 'SY-FDPOS'.
Thanks ,
Praveen -
Hey all.
I am playing around with the idea of finding a line of text within a text file, by using scanner and some next methods.
The way I am trying to get it to work is that one enters a string and the program then finds all the lines of text containing that
user-entered string and then prints them.
The text file in question contains names of University papers and their room numbers, quantity of students etc.
Example:
IBUS212 EALT006 1am 72 AL LI
BMSC241 MCLT102 2 pm 8 AL COOREY
My problem annoyingly enough seems to be that I can't think how one could compare the string entered to the lines of text being
scanned in the text file.
My latest go involved what you see in the code, scanning the examdata.txt file for a user-entered course number, using course.next();
by going with the example above it would be IBUS212. The task was to then to find all of the lines containing that number and print them out using
println (what I have tried with id and line) as well as the rest of that line eg: EALT006 1am 72 AL LI .
public void printCourse()
try
String details, input, id, line;
int count;
Scanner user = new Scanner(System.in);
System.out.println();
System.out.println();
System.out.println("Please enter your course ID: ");
input = user.nextLine();
Scanner course = new Scanner(new File("examdata.txt"));
course.next();
course.nextLine();
id = course.next();
line = course.nextLine();
if(input.equals(id))
System.out.println("Your course times are: " + id + "and" + line);
else
System.out.println("Your course does not exist.");
catch(IOException e)
System.out.print("File failure");
}Any advice/help/troubleshooting would be greatly appreciated.
Edited by: AUAN on Aug 13, 2009 9:43 AM
Edited by: AUAN on Aug 13, 2009 9:44 AM
Edited by: AUAN on Aug 13, 2009 9:49 AMYou'll want [to loop while|http://java.sun.com/docs/books/tutorial/java/nutsandbolts/while.html] the course Scanner has a next line and then print the line if it contains the entered text.
For useful methods you can check the Javadoc of String and Scanner (use your browser search on keywords like 'next' or 'contains' to find them). -
Search / Replace in Acrobat Pro 9 ??
I have a PDF that needs some significant editing. I can't go back to the source. I could accomplish a lot with a search / replace tool. I've been searching through the help files and information online and I can't figure out if there is a search/replace tool in this product. I have found the search / redact tool, but no search / replace. Does anyone know if Acro Pro 9 has this feature? If not, is there a free plugin that could do this...? and in which version of Acrobat did they introduce search/replace?
ThanksYes there is search replace in newer versions, at least according to Adobe. see here:
Acrobat Help | Searching PDFs
Find and replace text in PDFs
Find and replace text in a PDF
The Find toolbar searches the currently open PDF. You can selectively replace the search term with alternative text. You replace text one instance at a time. You cannot make a global change throughout a PDF or across multiple PDFs.
Choose Edit > Find (Ctrl/Command+F).
Type the text you want to search for in the text box on the Find toolbar.
To replace text, click Replace With to expand the toolbar, then type the replacement text in the Replace With text box. -
Is there a way to Find & Replace within a selection?
I looked in the User Guide, but I didn't find any information on how to Find & Replace just within selected text. I can see how to do it for the entire document or do it one instance at a time. Is there a trick I'm missing, or is this a missing feature?
Hey Chuck,
I opened Pages and used its help menu and came up with this. It does not specifically mention anything about choosing just 1 paragraph or text box, but I hope it helps you none the less.
+Finding and Replacing Text+
+You can find every instance of a word or phrase in your document, and optionally change it to something else.+
+Here are ways to find and replace text:+
+Choose Edit > Find > Find, click Simple or Advanced to set up find/replace criteria, and then click a button to conduct find/replace operations.+
+Simple: In the Find field, type the text you want to find, and type any text you want to replace it with in the Replace field.+
+Advanced: In addition to typing Find and Replace text, you can set up additional find/replace criteria.+
+Replace All: Automatically conducts the find/replace operation without your review.+
+Replace: Replaces the current selection with the replacement text.+
+Replace & Find: Replaces the current selection with the replacement text and immediately finds the next occurrence of the Find text.+
+Next or Previous: Finds the next or previous occurrence of the Find text.+
+Use the other commands on the Edit > Find submenu.+
+Find Next or Find Previous: Finds the next or previous occurrence of the current Find text.+
+Use Selection for Find: Finds the next occurrence of the selected text.+
+Jump to Selection: Displays the selected text when it’s not currently in view.+
Adam -
Hello All
Is there a way to do a "Search & Replace" in LabVIEW as in other e.g. text based programming languages?
In LabVIEW you can right click at the object and select replace. But when I have many of instances this procedure is getting long.
I know I can save other vi as the given vi, but this will replace also other instances in other projects, which I do not want.
Thanks in advance.
PawelThis could have partial usefulness for sub VIs, but not for plain LabVIEW items (who would want to do a global replace of all "add" with a "multiply"... ;-)
Unlike in text based languages, "replace" is not such a clear cut operation. What do do if the terminals don't match? Often, it requires a manual cleanup.
There are a few workarounds, depending on how your VIs are organized. Are both in user.lib?
For example, if you really need to replace a subVI in a complex application, save it as development distribution, quit LabVIEW, then use explorer to temporarily rename the obsolete subVI and replace it with the new VI using the old name. Now re-open the toplevel VI, doubleclick any instance of your new subVI and give it the new more appropriate name. Save e
verything again and all will be updated to call the new subVI using the new name.
Now rename the old subVI back to what it was so other projects that use it don't choke.
LabVIEW Champion . Do more with less code and in less time . -
[CC] Search&Replace: Bug only with Regular Expressions
Can you confirm the following behaviour/bug?
Steps to reproduce:
1 Create a new document in DW CC
2 Enter that text in the source code view:
<p>€</p>
3 Open Search&Replace
Field Search in: Current document
Field Search: Text
Field Search (3rd Field): €
Start Search
Result: As expected the "€" is found.
4 [x] Regular Expressions
Start Search
Result: "€" isn't found
Can you reproduce that?
Do you regard that as a bug like me?
If not, why please?
Do you think it is technically impossible for the developers to solve the task?
Do you think the developers forgot to gray out "text" in the choice box and allow regular expressions only in source code?
Thanks.Nice that you like the nick
Sure, I know that I can file a feature wish.
But my main interest in this forum is to know, what other users think about certain features, why they think so, which they miss, which they regard as a bug, ...
When I remember it right, you told me some time ago, that you don't use RegEx.
Than I understand, that everything around that feature is not important for you.
What I like to understand is, why you think the behaviour is logically.
For me it is the opposite.
You get a result with "Scope: Text", "[ ]RegEx".
And you get no result with "Scope: Text", "[x]RegEx".
Incredible strange.
I would appreciate, if you could explain more detailed your view. -
Search&Replace with wildcard?
I always use search and replace with Homesite but I wonder if
there is a way of using a wildcard? I often want to replace text at
the beginning and end of variable text. I mean, if I have this:
<h3>First text</h3>
<h3>Second text here</h3>
What I'd like is, using the * as a wildcard, is to use
something like this:
Replace <h3>*</h3> with <h2>*</h2>
Any ideas? Thanksyou can use the extended search/replace with regular
expressions to do this.
So for example. Bring up the Extended Replace (Ctrl + Shift +
R)
And in the Find box, put:
<h2>(.*)</h2>
in the Replace with box, put:
<h3>\1</h3>
note: \1 is the first match returned by the regular
expression -
Search & replace is broken in 10.9.4 Finnish OS X-version.
Search & replace is broken in 10.9.4 Finnish OS X-version.
This is global in the OS X.
I Found it out, when I tried to copy & paste & search and replace in the Xcode. After that in the Pages, and after that in the basic text editor.
Search & replace just do not nothing. Not even an error message.
Restarting system do not help, but turning OS X to english version transfers the problem to /dev/null 2>&1
This is really ******* me off. I REALLY do not want to use my OS X for english because of that, at then copy & paste & replace works. ARGH! This causes whacking delays to my coding work!Search & replace is broken in 10.9.4 Finnish OS X-version.
This is global in the OS X.
I Found it out, when I tried to copy & paste & search and replace in the Xcode. After that in the Pages, and after that in the basic text editor.
Search & replace just do not nothing. Not even an error message.
Restarting system do not help, but turning OS X to english version transfers the problem to /dev/null 2>&1
This is really ******* me off. I REALLY do not want to use my OS X for english because of that, at then copy & paste & replace works. ARGH! This causes whacking delays to my coding work! -
Need search & replace help dreamweaver 2006 (complicated question)
Hello:
if somebody could help with this I'd really appreciate it
....I have a site with tons of two word dir names word1_word2 a few are 3 word - there are a few images with this also (same as the dir names)
I generate the site with the dir names in the metatage (discription and keywords) and at various places in the pages
after building it I search and replace _ to space with dreamweaver (option not in any tag) so this kills the _ where ever it's visable but leaves it in img src and alt tags ect but most important leaves in metas where it looks like heck and I don't wan't it
I've tired Everything in dreamweaver to search it out of metas and can't - I can live with it in alt img ect but rather not
basic question"
(is there a regex to leave _ only in hrefs & css styles and replace with space Everywhere else - if not remove in all visable text & metatags)
beter yet can I do this with options in dreamweaver search & replace - 2 steps is ok - I killed the in visable text - I could live with them in alt & link titles but not in metatags (description and keywords)
please Keep in mind I need it in href's (not the visable text though)
thanks,
MEFJust so I get this straight, you want to change this:
http://example.com/Annette_O_Toole/index.html
to this:
http://example.com/Annette O Toole/index.html
Using spaces instead of underscores? That is not a good thing. You should never use spaces or special characters in folder or filenames. Ok?
I hope this answers your question. If not, post back with an example of what you're trying to change.
Nancy O.
Alt-Web Design & Publishing
Web | Graphics | Print | Media Specialists
www.alt-web.com/
www.twitter.com/altweb
www.alt-web.blogspot.com
Maybe you are looking for
-
Aperture 3 and Flickr syncing back and forth
I posted some pics to flickr using Aperture 3, and later added keywords, again using Aperture 3. I couldn't get the new keywords to sync up to my flickr page, something I'd been able to do previously. I hit the broadcast sync button, but it is not ad
-
How To Reinstall The Mac App Store?
When someone was on my computer they used App Cleaner to delete it entirely. I'm not sure if its a joke or whatever. How do I redownload/install it? I'm using a early 2011 MPB running Mac OS X Lion.
-
Mailbox mails to be remove through shell
Hi, I need to keep one of the mailbox mails to be reserve present two days only and past mails are to be removed. I have tried below command from exchange shell but it's not worked out. Get-Mailbox -identity [email protected] | Search-Mailbox -Search
-
The analysis of a Apache log file
What will you recommend for the analysis of a Apache log file?
-
Need query help regarding employee retirement age.
Need query to find employee retirement age 2years in advance.