Regex: Select empty spaces from a particular tab and replace them with one single space [duplicate]
This question already has an answer here:
Regex: Remove every two or more spaces between specific tags and leave just a space instead
3 answers
hello and Happy new year !
have a little problem with more then 2000 .html files. I need to select all empty spaces from the next particular tag, and to replace with just one space.
<p class="test_formal"> This is my text <em>and all of this</em> I have to go home .</p>
My regex is not very good :(
Search: (?s)(?:G)|<p class="text_formal">).*?|.*(?=</p>)|+h
Replace by: (Leave one space)
windows-10 notepad++ regex
marked as duplicate by harrymc, DavidPostill♦
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Dec 31 '18 at 16:58
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Regex: Remove every two or more spaces between specific tags and leave just a space instead
3 answers
hello and Happy new year !
have a little problem with more then 2000 .html files. I need to select all empty spaces from the next particular tag, and to replace with just one space.
<p class="test_formal"> This is my text <em>and all of this</em> I have to go home .</p>
My regex is not very good :(
Search: (?s)(?:G)|<p class="text_formal">).*?|.*(?=</p>)|+h
Replace by: (Leave one space)
windows-10 notepad++ regex
marked as duplicate by harrymc, DavidPostill♦
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Dec 31 '18 at 16:58
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Regex: Remove every two or more spaces between specific tags and leave just a space instead
3 answers
hello and Happy new year !
have a little problem with more then 2000 .html files. I need to select all empty spaces from the next particular tag, and to replace with just one space.
<p class="test_formal"> This is my text <em>and all of this</em> I have to go home .</p>
My regex is not very good :(
Search: (?s)(?:G)|<p class="text_formal">).*?|.*(?=</p>)|+h
Replace by: (Leave one space)
windows-10 notepad++ regex
This question already has an answer here:
Regex: Remove every two or more spaces between specific tags and leave just a space instead
3 answers
hello and Happy new year !
have a little problem with more then 2000 .html files. I need to select all empty spaces from the next particular tag, and to replace with just one space.
<p class="test_formal"> This is my text <em>and all of this</em> I have to go home .</p>
My regex is not very good :(
Search: (?s)(?:G)|<p class="text_formal">).*?|.*(?=</p>)|+h
Replace by: (Leave one space)
This question already has an answer here:
Regex: Remove every two or more spaces between specific tags and leave just a space instead
3 answers
windows-10 notepad++ regex
windows-10 notepad++ regex
edited Dec 31 '18 at 17:08
Rob Rob
asked Dec 31 '18 at 15:21
Rob RobRob Rob
32
32
marked as duplicate by harrymc, DavidPostill♦
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Dec 31 '18 at 16:58
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by harrymc, DavidPostill♦
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Dec 31 '18 at 16:58
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
- Select the part in which you want to make changes
- Ctrl+H
- Find what:
+
(space and plus sign) - Replace with:
(just space)
- Check
In selection
(or press Alt+I) - Click on
Replace all
button (or press Alt+A)
That's all :)
I have more then 2000 .html files. Cannot do this :)
– Rob Rob
Dec 31 '18 at 17:08
This will replace multiple spaces everywhere in the file. They want to replace ONLY inside<p..> ... </p>
– Toto
Dec 31 '18 at 17:35
add a comment |
Ctrl+H
- Find what:
(?:^<p class="text_formal">|G)Ks*(S+)
- Replace with:
$1
# a space then $1 - check Wrap around
- check Regular expression
- Replace all
Explanation:
(?: # start non capture group
^ # beginning of line
<p class="text_formal"> # literally
| # OR
G # restart from last match position
) # end group
K # forget all we have seen until this position
s* # 0 or more spaces
(S+) # group 1, 1 or more any character that is not a space
Result for given example:
<p class="test_formal"> This is my text <em>and all of this</em> I have to go home .</p>
Toto,$1 # a space then $1
means$1 $1
? Are you sure isnt it$1 $2
? Can you make an example on regex101.com ? I don't think it is working. Besides, seems that the regex put all the lines in a single line. try regex on more same lines
– Rob Rob
Dec 31 '18 at 17:11
@RobRob: I mean the replacement part is a space followed by$1
. Have a look at the duplicate question.
– Toto
Dec 31 '18 at 17:34
yes, ok, the problem is that regex moves all lines on a single line. And, it is not select only the particular tab, but all tags :) regex101.com/r/ybSQFD/1
– Rob Rob
Dec 31 '18 at 17:44
@RobRob: I can't do more, sorry. Look at the duplicate question. If it doesn't work, you have to write a script in your favorite scripting language.
– Toto
Dec 31 '18 at 18:04
something about this will be more easily, if is possible: Search:<p class="test_formal">[^Srn]+(.*)</p>
Replace by:(leave one space)
– Rob Rob
Jan 2 at 11:07
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
- Select the part in which you want to make changes
- Ctrl+H
- Find what:
+
(space and plus sign) - Replace with:
(just space)
- Check
In selection
(or press Alt+I) - Click on
Replace all
button (or press Alt+A)
That's all :)
I have more then 2000 .html files. Cannot do this :)
– Rob Rob
Dec 31 '18 at 17:08
This will replace multiple spaces everywhere in the file. They want to replace ONLY inside<p..> ... </p>
– Toto
Dec 31 '18 at 17:35
add a comment |
- Select the part in which you want to make changes
- Ctrl+H
- Find what:
+
(space and plus sign) - Replace with:
(just space)
- Check
In selection
(or press Alt+I) - Click on
Replace all
button (or press Alt+A)
That's all :)
I have more then 2000 .html files. Cannot do this :)
– Rob Rob
Dec 31 '18 at 17:08
This will replace multiple spaces everywhere in the file. They want to replace ONLY inside<p..> ... </p>
– Toto
Dec 31 '18 at 17:35
add a comment |
- Select the part in which you want to make changes
- Ctrl+H
- Find what:
+
(space and plus sign) - Replace with:
(just space)
- Check
In selection
(or press Alt+I) - Click on
Replace all
button (or press Alt+A)
That's all :)
- Select the part in which you want to make changes
- Ctrl+H
- Find what:
+
(space and plus sign) - Replace with:
(just space)
- Check
In selection
(or press Alt+I) - Click on
Replace all
button (or press Alt+A)
That's all :)
answered Dec 31 '18 at 16:17
Grzegorz SuprynGrzegorz Supryn
112
112
I have more then 2000 .html files. Cannot do this :)
– Rob Rob
Dec 31 '18 at 17:08
This will replace multiple spaces everywhere in the file. They want to replace ONLY inside<p..> ... </p>
– Toto
Dec 31 '18 at 17:35
add a comment |
I have more then 2000 .html files. Cannot do this :)
– Rob Rob
Dec 31 '18 at 17:08
This will replace multiple spaces everywhere in the file. They want to replace ONLY inside<p..> ... </p>
– Toto
Dec 31 '18 at 17:35
I have more then 2000 .html files. Cannot do this :)
– Rob Rob
Dec 31 '18 at 17:08
I have more then 2000 .html files. Cannot do this :)
– Rob Rob
Dec 31 '18 at 17:08
This will replace multiple spaces everywhere in the file. They want to replace ONLY inside
<p..> ... </p>
– Toto
Dec 31 '18 at 17:35
This will replace multiple spaces everywhere in the file. They want to replace ONLY inside
<p..> ... </p>
– Toto
Dec 31 '18 at 17:35
add a comment |
Ctrl+H
- Find what:
(?:^<p class="text_formal">|G)Ks*(S+)
- Replace with:
$1
# a space then $1 - check Wrap around
- check Regular expression
- Replace all
Explanation:
(?: # start non capture group
^ # beginning of line
<p class="text_formal"> # literally
| # OR
G # restart from last match position
) # end group
K # forget all we have seen until this position
s* # 0 or more spaces
(S+) # group 1, 1 or more any character that is not a space
Result for given example:
<p class="test_formal"> This is my text <em>and all of this</em> I have to go home .</p>
Toto,$1 # a space then $1
means$1 $1
? Are you sure isnt it$1 $2
? Can you make an example on regex101.com ? I don't think it is working. Besides, seems that the regex put all the lines in a single line. try regex on more same lines
– Rob Rob
Dec 31 '18 at 17:11
@RobRob: I mean the replacement part is a space followed by$1
. Have a look at the duplicate question.
– Toto
Dec 31 '18 at 17:34
yes, ok, the problem is that regex moves all lines on a single line. And, it is not select only the particular tab, but all tags :) regex101.com/r/ybSQFD/1
– Rob Rob
Dec 31 '18 at 17:44
@RobRob: I can't do more, sorry. Look at the duplicate question. If it doesn't work, you have to write a script in your favorite scripting language.
– Toto
Dec 31 '18 at 18:04
something about this will be more easily, if is possible: Search:<p class="test_formal">[^Srn]+(.*)</p>
Replace by:(leave one space)
– Rob Rob
Jan 2 at 11:07
add a comment |
Ctrl+H
- Find what:
(?:^<p class="text_formal">|G)Ks*(S+)
- Replace with:
$1
# a space then $1 - check Wrap around
- check Regular expression
- Replace all
Explanation:
(?: # start non capture group
^ # beginning of line
<p class="text_formal"> # literally
| # OR
G # restart from last match position
) # end group
K # forget all we have seen until this position
s* # 0 or more spaces
(S+) # group 1, 1 or more any character that is not a space
Result for given example:
<p class="test_formal"> This is my text <em>and all of this</em> I have to go home .</p>
Toto,$1 # a space then $1
means$1 $1
? Are you sure isnt it$1 $2
? Can you make an example on regex101.com ? I don't think it is working. Besides, seems that the regex put all the lines in a single line. try regex on more same lines
– Rob Rob
Dec 31 '18 at 17:11
@RobRob: I mean the replacement part is a space followed by$1
. Have a look at the duplicate question.
– Toto
Dec 31 '18 at 17:34
yes, ok, the problem is that regex moves all lines on a single line. And, it is not select only the particular tab, but all tags :) regex101.com/r/ybSQFD/1
– Rob Rob
Dec 31 '18 at 17:44
@RobRob: I can't do more, sorry. Look at the duplicate question. If it doesn't work, you have to write a script in your favorite scripting language.
– Toto
Dec 31 '18 at 18:04
something about this will be more easily, if is possible: Search:<p class="test_formal">[^Srn]+(.*)</p>
Replace by:(leave one space)
– Rob Rob
Jan 2 at 11:07
add a comment |
Ctrl+H
- Find what:
(?:^<p class="text_formal">|G)Ks*(S+)
- Replace with:
$1
# a space then $1 - check Wrap around
- check Regular expression
- Replace all
Explanation:
(?: # start non capture group
^ # beginning of line
<p class="text_formal"> # literally
| # OR
G # restart from last match position
) # end group
K # forget all we have seen until this position
s* # 0 or more spaces
(S+) # group 1, 1 or more any character that is not a space
Result for given example:
<p class="test_formal"> This is my text <em>and all of this</em> I have to go home .</p>
Ctrl+H
- Find what:
(?:^<p class="text_formal">|G)Ks*(S+)
- Replace with:
$1
# a space then $1 - check Wrap around
- check Regular expression
- Replace all
Explanation:
(?: # start non capture group
^ # beginning of line
<p class="text_formal"> # literally
| # OR
G # restart from last match position
) # end group
K # forget all we have seen until this position
s* # 0 or more spaces
(S+) # group 1, 1 or more any character that is not a space
Result for given example:
<p class="test_formal"> This is my text <em>and all of this</em> I have to go home .</p>
answered Dec 31 '18 at 16:04
TotoToto
3,735101226
3,735101226
Toto,$1 # a space then $1
means$1 $1
? Are you sure isnt it$1 $2
? Can you make an example on regex101.com ? I don't think it is working. Besides, seems that the regex put all the lines in a single line. try regex on more same lines
– Rob Rob
Dec 31 '18 at 17:11
@RobRob: I mean the replacement part is a space followed by$1
. Have a look at the duplicate question.
– Toto
Dec 31 '18 at 17:34
yes, ok, the problem is that regex moves all lines on a single line. And, it is not select only the particular tab, but all tags :) regex101.com/r/ybSQFD/1
– Rob Rob
Dec 31 '18 at 17:44
@RobRob: I can't do more, sorry. Look at the duplicate question. If it doesn't work, you have to write a script in your favorite scripting language.
– Toto
Dec 31 '18 at 18:04
something about this will be more easily, if is possible: Search:<p class="test_formal">[^Srn]+(.*)</p>
Replace by:(leave one space)
– Rob Rob
Jan 2 at 11:07
add a comment |
Toto,$1 # a space then $1
means$1 $1
? Are you sure isnt it$1 $2
? Can you make an example on regex101.com ? I don't think it is working. Besides, seems that the regex put all the lines in a single line. try regex on more same lines
– Rob Rob
Dec 31 '18 at 17:11
@RobRob: I mean the replacement part is a space followed by$1
. Have a look at the duplicate question.
– Toto
Dec 31 '18 at 17:34
yes, ok, the problem is that regex moves all lines on a single line. And, it is not select only the particular tab, but all tags :) regex101.com/r/ybSQFD/1
– Rob Rob
Dec 31 '18 at 17:44
@RobRob: I can't do more, sorry. Look at the duplicate question. If it doesn't work, you have to write a script in your favorite scripting language.
– Toto
Dec 31 '18 at 18:04
something about this will be more easily, if is possible: Search:<p class="test_formal">[^Srn]+(.*)</p>
Replace by:(leave one space)
– Rob Rob
Jan 2 at 11:07
Toto,
$1 # a space then $1
means $1 $1
? Are you sure isnt it $1 $2
? Can you make an example on regex101.com ? I don't think it is working. Besides, seems that the regex put all the lines in a single line. try regex on more same lines– Rob Rob
Dec 31 '18 at 17:11
Toto,
$1 # a space then $1
means $1 $1
? Are you sure isnt it $1 $2
? Can you make an example on regex101.com ? I don't think it is working. Besides, seems that the regex put all the lines in a single line. try regex on more same lines– Rob Rob
Dec 31 '18 at 17:11
@RobRob: I mean the replacement part is a space followed by
$1
. Have a look at the duplicate question.– Toto
Dec 31 '18 at 17:34
@RobRob: I mean the replacement part is a space followed by
$1
. Have a look at the duplicate question.– Toto
Dec 31 '18 at 17:34
yes, ok, the problem is that regex moves all lines on a single line. And, it is not select only the particular tab, but all tags :) regex101.com/r/ybSQFD/1
– Rob Rob
Dec 31 '18 at 17:44
yes, ok, the problem is that regex moves all lines on a single line. And, it is not select only the particular tab, but all tags :) regex101.com/r/ybSQFD/1
– Rob Rob
Dec 31 '18 at 17:44
@RobRob: I can't do more, sorry. Look at the duplicate question. If it doesn't work, you have to write a script in your favorite scripting language.
– Toto
Dec 31 '18 at 18:04
@RobRob: I can't do more, sorry. Look at the duplicate question. If it doesn't work, you have to write a script in your favorite scripting language.
– Toto
Dec 31 '18 at 18:04
something about this will be more easily, if is possible: Search:
<p class="test_formal">[^Srn]+(.*)</p>
Replace by: (leave one space)
– Rob Rob
Jan 2 at 11:07
something about this will be more easily, if is possible: Search:
<p class="test_formal">[^Srn]+(.*)</p>
Replace by: (leave one space)
– Rob Rob
Jan 2 at 11:07
add a comment |