Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

How to Search and replace everything within brackets??


  • Please log in to reply
3 replies to this topic
TH
  • Members
  • 76 posts
  • Last active: Jan 15 2012 06:22 PM
  • Joined: 28 Oct 2010
+6::
FileRead, Contents, C:\teste.txt

;~ newcon := RegExReplace (Contents, "a", "z") 
StringReplace, newcon, Contents, `(*[0-9]`), ZZ, All
StringReplace, newcon, Contents, `—[0-9]`., ZZ, All
FileAppend,
(
%newcon%
), C:\testeFINAL.txt

Return


Hello all!

My goal is to open a txt and replace every part this meets one of the following criteria with "nothing".

Criteria:
1- Is between paretheses AND the last characther before the closing parentheses is a number
2- Starts with — and the last the last characthers are a number followed by a dot.

I can't get RegExReplace to work even to go a simple "a" to "z" swap, so I'm using StringReplace.

Any ideas???

Thanks!

ps.: The "ZZ" is for testing purposes, than I'll chage it to ""

I'm using "autohotkey-L"

SoLong&Thx4AllTheFish
  • Members
  • 4999 posts
  • Last active:
  • Joined: 27 May 2007
test=

(

1 lajf k  (lsjf lsakfdsfj 1) dsfljldj fas

2 lajf(lsjf 2) dsfljldj fas

3 lsdja—asdflk2. fksafs

4 flkjaslf

)

MsgBox % RegExReplace(test, "imU)\(.*\d\)|—\w*\d\.", "*")





TH
  • Members
  • 76 posts
  • Last active: Jan 15 2012 06:22 PM
  • Joined: 28 Oct 2010
:shock: that's a big expression! It works great! Thanks!

Is there anywhere where all those commands are listed? I know "|" stands for "or" :lol:

I see you use \ instead of `

EDIT: FOund it!

<!-- m -->http://www.regular-e.../reference.html<!-- m -->

SoLong&Thx4AllTheFish
  • Members
  • 4999 posts
  • Last active:
  • Joined: 27 May 2007
<!-- m -->http://www.autohotke...Ex-QuickRef.htm<!-- m -->