简体   繁体   English

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

[英]How to compare the string and ignore the starting string from a sentence in JAVAScript

I want to check the text and know if the text content is exceeding more than 70 characters and show which ever line has exceeding characters. 我想检查文本并知道文本内容是否超过70个字符,并显示哪一行都超过了字符。 Code: 码:

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";

So my Question is if i can ignore the links in the text content which starts from 'http' and give the result for the texts exceeding 70 characters only not about the URLs length Answers will be very much appreciated. 所以我的问题是,如果我可以忽略以'http'开头的文本内容中的链接,并给出超过70个字符的文本结果,而不仅仅是URL长度的问题。答案将非常感谢。

Thank you, Sagar 谢谢萨加尔

you can use; 您可以使用;

String text= links.substring("http"+1, links.length()); 字符串文字= links.substring(“ http” +1,links.length());

text is a string without "http", for example: text是不带“ http”的字符串,例如:

links = " http://stackoverflow.com " 链接=“ http://stackoverflow.com

after you use my line code, you obtain 使用我的行代码后,您将获得

text= "://stackoverflow.com". 文字=“://stackoverflow.com”。

So, you should add this where you have the complete string 因此,您应该在具有完整字符串的位置添加它

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM