dongshao8471 2019-06-26 19:34
浏览 32

如何在字符串的特定位置找到准确的字符

I have the following string:

absoloute-power

As you can see, there is a "-" at position number 10 in the string. How do I write the go code to validate if the 10th position of any given string has a "-" in the string?

  • 写回答

3条回答 默认 最新

  • duanpang2751 2019-06-26 19:44
    关注

    You could use a rune-array:

    text := "ifthisisyourstring"
    chars := []rune(text)
    if chars[0] == '1' {
        // is true
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥20 XP系统在重新启动后进不去桌面,一直黑屏。
  • ¥15 opencv图像处理,需要四个处理结果图
  • ¥15 无线移动边缘计算系统中的系统模型
  • ¥15 深度学习中的画图问题
  • ¥15 java报错:使用mybatis plus查询一个只返回一条数据的sql,却报错返回了1000多条
  • ¥15 Python报错怎么解决
  • ¥15 simulink如何调用DLL文件
  • ¥15 关于用pyqt6的项目开发该怎么把前段后端和业务层分离
  • ¥30 线性代数的问题,我真的忘了线代的知识了
  • ¥15 有谁能够把华为matebook e 高通骁龙850刷成安卓系统,或者安装安卓系统