Remove the strong tag from a html string
up vote
0
down vote
favorite
I have s string containg a html text. I want to remove the strong tag from it and keep the text inside the tag.
For this input:
some text <strong> example </strong other text
the result should be:
some text example other text
I tried this but this is deleting the text inside the strong tag
String target = htmlString.replaceAll("<strong.*</strong>", "");
java
New contributor
elpmaxe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
up vote
0
down vote
favorite
I have s string containg a html text. I want to remove the strong tag from it and keep the text inside the tag.
For this input:
some text <strong> example </strong other text
the result should be:
some text example other text
I tried this but this is deleting the text inside the strong tag
String target = htmlString.replaceAll("<strong.*</strong>", "");
java
New contributor
elpmaxe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2
Is itjava
orjavascript
? Sounds more like java, to me. Besides, the input provided has</strong
instead of</strong>
. Is it intended?
– briosheje
2 days ago
"some text <strong> example </strong other text".replace('<strong>','').replace('</strong','')
– shaghayegh sheykholeslami
2 days ago
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have s string containg a html text. I want to remove the strong tag from it and keep the text inside the tag.
For this input:
some text <strong> example </strong other text
the result should be:
some text example other text
I tried this but this is deleting the text inside the strong tag
String target = htmlString.replaceAll("<strong.*</strong>", "");
java
New contributor
elpmaxe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I have s string containg a html text. I want to remove the strong tag from it and keep the text inside the tag.
For this input:
some text <strong> example </strong other text
the result should be:
some text example other text
I tried this but this is deleting the text inside the strong tag
String target = htmlString.replaceAll("<strong.*</strong>", "");
java
java
New contributor
elpmaxe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
elpmaxe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited 2 days ago
Mohammad
12.7k93158
12.7k93158
New contributor
elpmaxe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 2 days ago
elpmaxe
6
6
New contributor
elpmaxe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
elpmaxe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
elpmaxe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2
Is itjava
orjavascript
? Sounds more like java, to me. Besides, the input provided has</strong
instead of</strong>
. Is it intended?
– briosheje
2 days ago
"some text <strong> example </strong other text".replace('<strong>','').replace('</strong','')
– shaghayegh sheykholeslami
2 days ago
add a comment |
2
Is itjava
orjavascript
? Sounds more like java, to me. Besides, the input provided has</strong
instead of</strong>
. Is it intended?
– briosheje
2 days ago
"some text <strong> example </strong other text".replace('<strong>','').replace('</strong','')
– shaghayegh sheykholeslami
2 days ago
2
2
Is it
java
or javascript
? Sounds more like java, to me. Besides, the input provided has </strong
instead of </strong>
. Is it intended?– briosheje
2 days ago
Is it
java
or javascript
? Sounds more like java, to me. Besides, the input provided has </strong
instead of </strong>
. Is it intended?– briosheje
2 days ago
"some text <strong> example </strong other text".replace('<strong>','').replace('</strong','')
– shaghayegh sheykholeslami
2 days ago
"some text <strong> example </strong other text".replace('<strong>','').replace('</strong','')
– shaghayegh sheykholeslami
2 days ago
add a comment |
2 Answers
2
active
oldest
votes
up vote
3
down vote
htmlString.replace(/<strong>|</strong>/g, "");
New contributor
MrAleister is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
up vote
0
down vote
public class Stack_Ex {
public static void main(String args) {
String text = "some text <strong> example </strong other text";
text = text.replaceFirst(" <strong>","");
text = text.replaceFirst(" </strong","");
System.out.println(text);
}}
Output: some text example other text
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
htmlString.replace(/<strong>|</strong>/g, "");
New contributor
MrAleister is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
up vote
3
down vote
htmlString.replace(/<strong>|</strong>/g, "");
New contributor
MrAleister is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
up vote
3
down vote
up vote
3
down vote
htmlString.replace(/<strong>|</strong>/g, "");
New contributor
MrAleister is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
htmlString.replace(/<strong>|</strong>/g, "");
New contributor
MrAleister is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
MrAleister is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
answered 2 days ago
MrAleister
27019
27019
New contributor
MrAleister is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
MrAleister is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
MrAleister is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
add a comment |
up vote
0
down vote
public class Stack_Ex {
public static void main(String args) {
String text = "some text <strong> example </strong other text";
text = text.replaceFirst(" <strong>","");
text = text.replaceFirst(" </strong","");
System.out.println(text);
}}
Output: some text example other text
add a comment |
up vote
0
down vote
public class Stack_Ex {
public static void main(String args) {
String text = "some text <strong> example </strong other text";
text = text.replaceFirst(" <strong>","");
text = text.replaceFirst(" </strong","");
System.out.println(text);
}}
Output: some text example other text
add a comment |
up vote
0
down vote
up vote
0
down vote
public class Stack_Ex {
public static void main(String args) {
String text = "some text <strong> example </strong other text";
text = text.replaceFirst(" <strong>","");
text = text.replaceFirst(" </strong","");
System.out.println(text);
}}
Output: some text example other text
public class Stack_Ex {
public static void main(String args) {
String text = "some text <strong> example </strong other text";
text = text.replaceFirst(" <strong>","");
text = text.replaceFirst(" </strong","");
System.out.println(text);
}}
Output: some text example other text
answered 2 days ago
Vladislav Penchev
32
32
add a comment |
add a comment |
elpmaxe is a new contributor. Be nice, and check out our Code of Conduct.
elpmaxe is a new contributor. Be nice, and check out our Code of Conduct.
elpmaxe is a new contributor. Be nice, and check out our Code of Conduct.
elpmaxe is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53373792%2fremove-the-strong-tag-from-a-html-string%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
Is it
java
orjavascript
? Sounds more like java, to me. Besides, the input provided has</strong
instead of</strong>
. Is it intended?– briosheje
2 days ago
"some text <strong> example </strong other text".replace('<strong>','').replace('</strong','')
– shaghayegh sheykholeslami
2 days ago