Need help trimming characters


#1

Until a couple weeks ago, I had the regex's to trim x number of characters at y position from the left and right side of the string. Then, my HD went toes up and I had to restore from a month-old backup, and lost them. Can somebody help? I cannot figure out how they went. I'll give you an example of what I want it to do.

String: abcdefghijklmonpqrstuvwxyz
trim 11 characters from the left at position 10

result:

String: abcdefghijvwxyz

trim 5 characters from the right at position 2

result:

String: abcdefghijklmonpqrsyz

Any help?


#2

Regexp: ^(.{10}).{11}(.+)
Replace: $1$2


Regexp: (.+).{5}(.{2})$
Replace: $1$2


Notice how the two regexp work in both attachments. Pay close attention to the anchors ^ and $.




#3

Thank you very much, that works great. And yes, I need to pull my head out when it comes to anchors.

Now, I have saved the config to another drive with it's own backup, and to my data backup flash drive, so i don't have to ask again :laughing:

now, to continue :book: so i can learn more.


#4

Glad it works for you.

The world is now your oyster http://www.regular-expressions.info

See anchors listed on the side menu.