Remove Span Tag With Text from String

Remove Span tag with text from String

May be this will help you:

String yourString = "<span class=\"exam-dates-title\">Exam</span>Welcome";
int index = yourString.lastIndexOf(">");

String result = yourString.substring(index + 1, yourString.length());

how to remove span tag from the string?

For your edited question you can do this:

var str = // your string here

str = str.replace(/<\/?span[^>]*>/g,"");

Demo: http://jsfiddle.net/vXXJ6/

PHP Regex Pattern, removing span tags and inner text from string

This should be it.. The [*] matches the * character while the .*> matches any up till the > character

 if (substr_count($value, '*<span') > 0) {
$value = preg_replace('/[*].*>/', '', $value);
}

Regex to remove span tags using php

You can remove all tag using preg_replace('/<[^>]*>/', '', $content);

And also you can remove only span tag preg_replace('/<span[^>]+\>/i', '', $content); using this:

<?php 
$content = '<div><span class="smw smw-inline smw-basic smw-ct-default smw-visible" data-symbol="GSD.V" data-type="inline" data-refresh-frequency="5" data-source="live">
<span class="smw-market-data-field smw-field-l1" data-field="l1">0.65</span>
</span></div>';

echo $string = preg_replace('/<[^>]*>/', '', $content);

echo $new_string = preg_replace('/<span[^>]+\>/i', '', $content);
?>

How can I remove HTML tags other than div and span from a string in JavaScript?

To remove all tags excluding specific tags, you can use the following regular expression.

const str = "<div><p></p><span></span></div>";
console.log(str.replace(/(<\/?(?:span|div)[^>]*>)|<[^>]+>/ig, '$1'));

Remove span tag from element html dom parser

May be you can replace that span tag with blank:

echo $info['diesel']=str_replace("<span>zł</span>","",$info['diesel']);


Related Topics



Leave a reply



Submit