How to delete leading white/blank spaces in each line which begins with `<`
-
I read the matter here: Delete-blank-lines-of-multiple-opened-files/5 and want to ask, "How to delete leading white/blank spaces in each line which begins with
<
" -
Hello, @ramanand-jhingade,
I’m wondering : How a line which begins with the
<
character can have leading blank chars (space
/tab
) !?BR
guy038
-
I’m sure what is meant is that a bunch of whitespace leads off a line, then a
<
occurs, and the OP just wants to get rid of the whitespace before the<
but ugh, how many of these infinite regex questions of an easy nature are we going to have to endure here? -
You have been given at least 5 previous freebies – one for each of the Topics you have started. You have also been repeatedly pointed to advice on how to ask questions, and references for where to learn regex.
Please show some effort: show that you’ve read the docs, show what you’ve tried, show your data, and ask targeted questions if there’s something you’re not understanding. But repeatedly asking us to do your job/homework for you is not a good way to get help.
-
Hi, @ramanand-jhingade, @alan-kilborn, @peterjones and All,
Not difficult, indeed ! So, with the @alan-kilborn’s interpretation, use the following regex S/R :
SEARCH
^\h+(?=<)
REPLACE
Leave EMPTY
As usual, tick the
Wrap around
option, select theRegular expression
search mode and click on theReplace All
buttonBest Regards,
guy038
-
@guy038 said in How to delete leading white/blank spaces in each line which begins with `<`:
^\h+(?=<)
@guy038
For example, I had this:-<P </p <li </li </a <a href </span <span <ul </ul <ol </ol <div </div <br <U </u <H3 </h3 <h1 </h1 <h2 </h2 <h4 </h4 <h5 </h5
Using your regex, it became:-
<P </p <li </li </a <a href </span <span <ul </ul <ol </ol <div </div <br <U </u <H3 </h3 <h1 </h1 <h2 </h2 <h4 </h4 <h5 </h5
but I want it to be:-
<P </p <li </li </a <a href </span <span <ul </ul <ol </ol <div </div <br <U </u <H3 </h3 <h1 </h1 <h2 </h2 <h4 </h4 <h5 </h5
All the leading white spaces / blank spaces should disappear but it should happen only for the lines which begin with a
<
-
I copied the data you showed, then used the regex that @guy038 provided, and I got exactly the data that you desired.
It works for me.
You either didn’t use the same example data that you gave to us, or there is something else going on that we cannot see.
With View > Show Symbol > Show All Characters active, I started with
and ended up with
BTW: once again, your example data didn’t follow all my advice, so I’ll include my advice again. Notice how it highly recommends showing data that should change and showing data that shouldn’t change. (Guy’s expression works for your data, and will properly avoid ones that don’t start with <, but your test data won’t prove that to yourself)
----
Do you want regex search/replace help? Then please be patient and polite, show some effort, and be willing to learn; answer questions and requests for clarification that are made of you. All example text should be marked as literal text using the
</>
toolbar button or manual Markdown syntax. To makeregex in red
(and so they keep their special characters like *), use backticks, like`^.*?blah.*?\z`
. Screenshots can be pasted from the clipboard to your post usingCtrl+V
to show graphical items, but any text should be included as literal text in your post so we can easily copy/paste your data. Show the data you have and the text you want to get from that data; include examples of things that should match and be transformed, and things that don’t match and should be left alone; show edge cases and make sure you examples are as varied as your real data. Show the regex you already tried, and why you thought it should work; tell us what’s wrong with what you do get. Read the official NPP Searching / Regex docs and the forum’s Regular Expression FAQ. If you follow these guidelines, you’re much more likely to get helpful replies that solve your problem in the shortest number of tries. -
@PeterJones It worked for the files in my folder. Thanks!
@guy038 I thank you also. You are terrific - the Regex Guru as some are calling you!
@Alan-Kilborn I searched online and could not find a solution which is why I asked here. Please don’t get irritated. Thanks!