Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I need to replace something like this:

userPassword: {SSHA}hLPcGtsS+sUhwlYq/23dsECuRGsvJj59OQXXJQ==

with something like this:

userPassword:funkypassword

I have tried some random stuff I've found, but no luck. What would the code be with regexp?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

To match the last 40 characters of a line you would use the regex:

.{40}$

This means: "Match any character 40 times followed by end of line".

If you're interested in replacing the entire line you would use the regex

^(.*)(.{46})$

and a Replacement text of

first part:\1 second part:\2

would change your example text to

first part:userPassword:  second part:{SSHA}hLPcGtsS+sUhwlYq/23dsECuRGsvJj59OQXXJQ==

The brackets create a capture group and notepad++ replaces \n with the nth capture group.

Alternatevly, for your particular example (depends on what the other lines look like) you could use a pattern of

^(userPassword:).*$

Which simply matches all lines starting with "userPassword:".

share|improve this answer
1  
Can you add some explanation of why this answers the question. –  ChrisF Apr 24 '13 at 22:03
    
You sir rock, thank you! I ended up just using the ^(userPassword:).*$ the other method confused me a bit. –  Anthony Apr 25 '13 at 14:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.