如何比较字符串并忽略JAVAScript中句子的起始字符串

时间:2013-10-24 06:55:30

标签: javascript html comparison

我想检查文本并知道文本内容是否超过70个字符 并显示哪一行超过了字符。 代码:

if((str.charAt(i) != '\n') && (i!=(len-1)))
    {
        TChars = TChars + 1;
    }
    else
    {
        if(TChars >= 71)
        {
            Tres =  Tres + Lno + ", ";
        }
        TChars = 0;
        Lno = Lno + 1;

    } if(Tres.length < 1)

Tres = "No ";

document.AsciiConvert.HTMLResults.value += Tres + "line number have more than 70 characters.\n";

所以我的问题是,如果我可以忽略文本内容中从“http”开始的链接,并且只为超过70个字符的文本提供结果,而不是关于URL长度 答案将非常感谢。

谢谢你, Sagar的

1 个答案:

答案 0 :(得分:0)

你可以使用;

String text = links.substring(“http”+ 1,links.length());

text是没有“http”的字符串,例如:

links =“http://stackoverflow.com

使用我的行代码后,您将获得

text =“://stackoverflow.com”。

所以,你应该在你拥有完整字符串

的地方添加它