标签: ends-with

endsWith在JavaScript中

如何检查字符串是否以JavaScript中的特定字符结尾?

示例:我有一个字符串

var str = "mystring#";
Run Code Online (Sandbox Code Playgroud)

我想知道该字符串是否以#.结尾.我怎么检查呢?

  1. endsWith()JavaScript中有方法吗?

  2. 我有一个解决方案是获取字符串的长度并获取最后一个字符并检查它.

这是最好的方式还是有其他方式?

javascript string ends-with

1085
推荐指数
14
解决办法
44万
查看次数

查找字符串是否以C++中的另一个字符串结尾

如何在C++中查找字符串是否以另一个字符串结尾?

c++ string ends-with

252
推荐指数
10
解决办法
16万
查看次数

R是否具有像python一样的开头或结尾的功能?

正在寻找名称以某些子字符串开头的预测变量,找不到任何类似的函数.

python string r startswith ends-with

62
推荐指数
4
解决办法
5万
查看次数

Xpath"ends-with"不起作用

我试图找到一个动态ID名称始终以"register"结尾的输入元素.到目前为止我试过这个

"//input[@id[ends-with(.,'register')]]"
Run Code Online (Sandbox Code Playgroud)

还有这个

"//input[ends-with(@id,'register')]"
Run Code Online (Sandbox Code Playgroud)

这些都不会导致元素.我究竟做错了什么?同时这工作:

"//input[@id[contains(.,'register')]]"
Run Code Online (Sandbox Code Playgroud)

这是源的一部分:

<td class="input">
<input id="m.f0.menu.f2.volumeTabs.BLOCK_COMMON.tcw.form.register" name="m.f0.menu.f2.volumeTabs.BLOCK_COMMON.tcw.form.register" class="aranea-checkbox" type="checkbox"> </td>
Run Code Online (Sandbox Code Playgroud)

xpath ends-with

46
推荐指数
2
解决办法
5万
查看次数

在Java中使用startsWith和endsWith时如何忽略大小写?

这是我的代码:

public static void rightSel(Scanner scanner,char t)
{
  /*if (!stopping)*/System.out.print(": ");
    if (scanner.hasNextLine())
    {
     String orInput = scanner.nextLine;
        if (orInput.equalsIgnoreCase("help")
        {
            System.out.println("The following commands are available:");
            System.out.println("    'help'      : displays this menu");
            System.out.println("    'stop'      : stops the program");
            System.out.println("    'topleft'   : makes right triangle alligned left and to the top");
            System.out.println("    'topright'  : makes right triangle alligned right and to the top");
            System.out.println("    'botright'  : makes right triangle alligned right and to the bottom");
            System.out.println("    'botleft'   : makes right triangle …
Run Code Online (Sandbox Code Playgroud)

java string startswith case-insensitive ends-with

27
推荐指数
2
解决办法
3万
查看次数

Python endswith()有多个字符串

我有一个字符串:

myStr = "Chicago Blackhawks vs. New York Rangers"
Run Code Online (Sandbox Code Playgroud)

我也有一个清单:

myList = ["Toronto Maple Leafs", "New York Rangers"]
Run Code Online (Sandbox Code Playgroud)

使用endswith()方法,我想写一个if语句,检查myString是否以myList中的任何一个字符串结尾.我有基本的if语句,但我对我应该在括号中加入来检查这个问题感到困惑.

if myStr.endswith():
    print("Success")
Run Code Online (Sandbox Code Playgroud)

python python-2.7 python-3.x ends-with

15
推荐指数
2
解决办法
4422
查看次数

AttributeError:'NoneType'对象没有属性'endswith'

我目前正在开发一个更新网页的Python脚本.但是运行主脚本会产生以下错误:

<res status='-1'><error message="'NoneType' object has no attribute 'endswith'"><![CDATA[
Traceback (most recent call last):
  File "/path/to/file/ws_config.py", line XXXX, in Run
    tests = TestList().tests
  File "/path/to/file/ws_config.py", line XXXX, in __init__
    UpdateTestGroup(None),
  File "/path/to/file/ws_config.py", line XXXX, in __init__
    test = CT.CurlTest(settings),
  File "/path/to/file/config_tests.py", line XXXX, in __init__
    self.params.path = os.path.join('/', os.path.join(params.dir, params.file))
  File "/usr/lib/python2.6/posixpath.py", line 67, in join
    elif path == '' or path.endswith('/'):
AttributeError: 'NoneType' object has no attribute 'endswith'
Run Code Online (Sandbox Code Playgroud)

我不能通过任何代码,因为太长了.我想要了解的是错误的位置或代码的哪一部分触发了AttributeError.你能帮我么???

python attributeerror nonetype ends-with

11
推荐指数
1
解决办法
2万
查看次数

如何确定一个字符串"以"结束于R中的另一个字符串?

我想过滤掉在列的字符串值中包含'*'的表的行.只检查该列.

 string_name = c("aaaaa", "bbbbb", "ccccc", "dddd*", "eee*eee")

 zz <- sapply(tx$variant_full_name, function(x) {substrRight(x, -1) =="*"})
 Error in FUN(c("Agno I30N", "VP2 E17Q", "VP2 I204*", "VP3 I85F", "VP1 K73R",  : 
   could not find function "substrRight"
Run Code Online (Sandbox Code Playgroud)

由此,zz的第4个值应该为TRUE.

在python中有字符串的endswith函数[string_s.endswith('*')]是否有类似于R的东西?

此外,它是否有问题,因为'*'作为一个字符,因为它意味着任何字符?grepl也没有用.

> grepl("*^",'dddd*')
[1] TRUE
> grepl("*^",'dddd')
[1] TRUE
Run Code Online (Sandbox Code Playgroud)

string r ends-with

10
推荐指数
4
解决办法
1万
查看次数

Powershell命令修剪路径,如果它以"\"结束

如果它结束,我需要修剪路径\.

C:\Ravi\
Run Code Online (Sandbox Code Playgroud)

我需要换到

C:\Ravi
Run Code Online (Sandbox Code Playgroud)

我有一个路径不会结束的情况\(然后它必须跳过).

我尝试过.EndsWith("\"),但是当我有\\而不是时,它失败了\.

这可以在PowerShell中完成,而无需诉诸条件吗?

powershell text-parsing filepath ends-with

10
推荐指数
2
解决办法
8616
查看次数

属性值以特定字符串结尾的元素的XPath?

鉴于HTML包含:

  <div tagname="779853cd-355b-4242-8399-dc15f95b3276_Destination" class="panel panel-default"></div>
Run Code Online (Sandbox Code Playgroud)

我们如何在XPath中编写以下表达式:

查找属性以字符串'Destination'结尾的<div>元素tagname

我一直在寻找几天,我无法想出一些有用的东西.在众多中,我试过例如:

div[contains(@tagname, 'Destination')]
Run Code Online (Sandbox Code Playgroud)

html xml xpath ends-with

6
推荐指数
3
解决办法
7764
查看次数