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 have following lines of data:

X1+0X2+0X3+0X4+0X5+0X6+0X7-0.25X8-0.25X9-0.25X10-0.25X11+0X12+0X13+0X14+0.8X15+0X16+0X17+0X18

X1+0X2+0X3+0X4+0X5+0X6+0X7-0.25X8-0.25X9-0.25X10-0.25X11+0X12+0X13+0X14+0.89404X15+0X16+0X17+0X18

X1+0X2+0X3+0X4+0X5+0X6+0X7-0.25X8-0.25X9-0.25X10-0.25X11+0X12+0X13+0X14+0.93532X15+0X16+0X17+0X18

I wish to delete the string X15, the preceding +, and any characters in between using regex.

For example, the regex replace should return the following from my sample lines:

X1+0X2+0X3+0X4+0X5+0X6+0X7-0.25X8-0.25X9-0.25X10-0.25X11+0X12+0X13+0X14+0X16+0X17+0X18

X1+0X2+0X3+0X4+0X5+0X6+0X7-0.25X8-0.25X9-0.25X10-0.25X11+0X12+0X13+0X14+0X16+0X17+0X18

X1+0X2+0X3+0X4+0X5+0X6+0X7-0.25X8-0.25X9-0.25X10-0.25X11+0X12+0X13+0X14+0X16+0X17+0X18

Can someone please provide some suggestions and thoughts on this?

Thank you very much.

share|improve this question

1 Answer 1

I don't know Notepad++ but the way I would do that is:

Replace:

\+[^+]*X15

With nothing

share|improve this answer
    
Thanks for the response. I tried to use it, but it displays an error as "Invalid regular expression". I am quite new to regular expression. –  Naren Mar 27 at 3:05
1  
I think I figured that out. Since + is a regular expression keyword, I would have to give the search string as \+[^\+]*X15 Thank you very much for help. I appreciate it –  Naren Mar 27 at 3:13
    
There are different ways that programs handle regular expressions. I didn't know if Notepad++ used + or not. Now I know. I edited my answer to reflect that. –  mlv Mar 27 at 11:49
    
@Naren You don't need to put the backslash within the negated class, that is, it's perfectly fine with \+[^+]*X15. –  Jerry Mar 27 at 11:53
2  
@Naren If this answer solved your question, please select it as accepted. –  Kard Nails Mar 27 at 20:53

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.