question: remove characters from certain position

Discuss and share scripts and script files...
Post Reply
yusef88
Posts: 1148
Joined: 28 Jan 2013 03:50
Location: Windows 8.1 32-bit

question: remove characters from certain position

Post by yusef88 »

the following script inserts characters into certain position, can the operation be reversed to remove them?

Code: Select all

"Insert Character(s)" $char = input ("Enter the character to insert:");
  $pos = input ("Enter position to enter the character:");
  rename "r", "^(.{$pos})(.+)$ > $1$char$2", "p"

highend
Posts: 14940
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: question: remove characters from certain position

Post by highend »

That depends. From the same script (where you still have access to the $pos or $character variable)? Sure. In the same way like before (a rename with a regex pattern and the usage of a range ({})...
One of my scripts helped you out? Please donate via Paypal

yusef88
Posts: 1148
Joined: 28 Jan 2013 03:50
Location: Windows 8.1 32-bit

Re: question: remove characters from certain position

Post by yusef88 »

sorry I'm not familiar with scripts. let's say 4th character is to be removed, how :?:

highend
Posts: 14940
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: question: remove characters from certain position

Post by highend »

Code: Select all

rename "r", "^(.{3}).(.*)$ > $1$2", "p"
One of my scripts helped you out? Please donate via Paypal

yusef88
Posts: 1148
Joined: 28 Jan 2013 03:50
Location: Windows 8.1 32-bit

Re: question: remove characters from certain position

Post by yusef88 »

grateful :beer:

Post Reply