Remplace text in middle on line

Tool for Search and Replace across multiple files.
User avatar
Fool4UAnyway

Post by Fool4UAnyway »

Are you using the Regular Expression tab, or just performing a Standard (absolute) search?

You may also use the Regular Expression tester to load a single file, or just enter a few lines manually, and play with (parts of) the regular expressions mentioned above to see what Text Crawler does and it does not find.
User avatar
Fool4UAnyway

Post by Fool4UAnyway »

Just try \d+ in the Regular Expression Tester...

"_ represents a space character" means: I entered an underscore character here to make the character( position)s clear. Some forums do remove leading white spaces. But when using such an expression, you will simply have to press the space bar once for each _.
User avatar
Fool4UAnyway

Post by Fool4UAnyway »

You could also use this regular expression that shouldn't suffer from any white space shredding of forums:

[ ][\d\.]+[ ]'UNDEF'

[ ] = the set ([]) of only a space character, so just a single space character
\d = the set of digits 0 through 9 = [0-9]

[\d\.] = any digit 0 through 9 or a dot
User avatar
Helen

Post by Helen »

I started a search for image files and asked for png & gif images to be excluded, but it included them...any idea what went wrong? Would appreciate any help.
User avatar
DV2

Post by DV2 »

Did you separate the names by semicolons?
eg
*.png;*.gif

I assume you are referring to Duplicate Cleaner, is textcrawler doesn't do too well with image files...
Kristen
Posts: 1
Joined: Sun Jun 02, 2013 8:13 am

Re: example using a wildcard to find/replace a text sequence

Post by Kristen »

Hi,

Thanks for the posts on the topic which helped me find a solution. I wanted to do something similar using wildcards.

I have multiple files in which I'd like to add a few extra lines of code, by searching text using a wildcard.

Say my text looks like this:
output_filename <- "IBRAe10_5Maamphibians0025_training_GDM.csv"

The "wildcard" search I used is this:
output_filename <- "IBRAe10_([^,]*)_GDM.csv"

and so my replace code looks like this:
output_filename <- "IBRAe10_$1_GDM.csv"
output_filename2 <- "IBRAe10_$1_GDM_wt2.csv"
output_filename3 <- "IBRAe10_$1_GDM_nowt.csv"

Which writes as:
output_filename <- "IBRAe10_5Maamphibians0025_training_GDM.csv"
output_filename2 <- "IBRAe10_5Maamphibians0025_training_GDM_wt2.csv"
output_filename3 <- "IBRAe10_5Maamphibians0025_training_GDM_nowt.csv"

May not have much finesse, but it worked...
Post Reply