PDA

View Full Version : Help with prefixes


koppa
08-27-2007, 03:42 AM
Say I have a list of words..

ask
in
message
thread
image
add
name

and I want to add a + to the front of each one

+ask
+in
+message

ect.

Now picture I have a list of 10,000 words. How can I add a prefix to all of them really quickly, without manually typing it in front of each one?

Thanks. I need to put a prefix in front of a bunch of words for a project I am working on.

Josh
08-27-2007, 07:04 AM
Hey hey!!

Is this a 1 off or something you want to do via a scripting language online? I know of a "cheap" work around that is offline I'll talk you through it:

1. Download Notepad++ (http://notepad-plus.sourceforge.net/uk/about.php) free open source editor
2. Open your file
3. Highlight all the words (ctrl+a)
3. Go-to Edit > Insert Tab
4. Highlight the "Tab" character infront of just 1 of the words
5. Press ctrl+F and click the replace tab
6. The "Find what" box should have a box in it, that represents the tab character
7. Fill the "Replace With" box with your "+" sign and click replace all

It worked for me just then with a test file, g'luck

koppa
08-27-2007, 03:25 PM
awesome, thanks!

How can I do this with the suffix now?

I was thinking of something like this(ssh):
cat file | awk '{print "(prefix)"$1"(suffix)"}' >> new_file

koppa
09-09-2007, 02:54 AM
sorry to bump the topic but,

does anyone know?

Josh
09-09-2007, 08:18 AM
Hm, I kind of got a result with another cheap work-around using notepad++ lol..

1. Open up your file with the prefix's
2. Select all (ctrl+a)
3. goto Edit > Join Lines (you should now just have 1 massive line)
4. (still select all) Press ctrl+F and go to replace, replace your prefix symbol with *your desired suffix sign* then <br>then your prefix sign e.g.
*<br>+
5. Replace all
6. Goto File > Save As .. save as a web page (filename.html)
7. Open up your file in an internet browser and save that page as text file.

The top 1 will have a random suffix and the last line won't have one so you'll ned to manually move that 1 to the bottom ;)

Just make sure your prefix/suffix's aren't symbols already in the files that your going to replace. let me know if it works :top:

koppa
09-10-2007, 12:39 AM
thanks much. :)

Josh
09-10-2007, 06:43 AM
No probs :top: