1

Like I said,, I want to search each line, from a word at the beginning of the line, To another word at the end !

For Example, let's say that I've a text file, that contains these lines :-

1.RA.xm: Width="224" Height="40" Type>BX15
2.RA.xm: Width="235" Height="43" Type>BX23
3.RA.xm: Width="215" Height="51" Type>BX84

I want to search for the part from xm to Type in each line, and Replace with nothing

So, the result is going to be like this:-

1.RA.>BX15
2.RA.>BX23
3.RA.>BX84

It doesn't matter what tool I have to use for this. But please If it possible, I prefer using a GUI App Regex (like NP++), Or By using any command line tool (I've Cygwin & GNUWin on my system)

I'd be so grateful for anyone can help...Thanks

3 Answers 3

1
sed 's/xm.*Type//' file

That deletes from the first instance of xm to the last instance of Type
.* means zero or more ("*") of any character (".")

3
  • Both answers are right and so useful to me . I don't know how to accept both of them as the correct answers that solved my problem , but I was able to make them both as useful answers . Thank you Bro for your help, I wish you all success in life :)
    – KorkOoO
    Sep 25, 2014 at 5:14
  • Hello again Bro... I'm facing another problem, and I need your help please. I want to use sed to search a text file for this </Graph>, and replace it with nothing. I've tried to find any solution for that slash problem, but none worked for me. I've tried to use this command sed -e s:</Graph>:g "InPut.txt" > "OutPut.txt" So, what's your suggestions in this case ? - Thanks -
    – KorkOoO
    Sep 25, 2014 at 14:03
  • The s/// command need 3 delimiters, and you only gave 2: sed 's:</Graph>::g' -- search for "</Graph>" and replace with "" Sep 25, 2014 at 14:33
1

For Notepad++, use this find pattern:

xm.*?Type

and replace with nothing.

.*? matches everything between xm and the first instance of Type that follows on the same line. Check your settings to make sure that . does NOT match newline characters.

1
  • Thanks So Much Excellll, I really appreciate your help...
    – KorkOoO
    Sep 25, 2014 at 5:03
0

This does the job:

  • Find what: (.*RA.xm:)(.*?)*?(Type>.*?)

  • Replace with: \1>\4

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .