【问题标题】:Trim leading and trailing spaces after "=" symbols in string c++修剪字符串c ++中“=”符号后的前导和尾随空格
【发布时间】:2015-08-01 08:12:33
【问题描述】:

我有一行数据带有“=”符号。我需要忽略字符串中“=”符号之前和之后的所有空格 例子: 输入我有:“这是 test = test1 和 test1= test2”

我正在寻找的输出: "这是 test=test1 和 test1=test2"

我已尝试使用 istream 忽略函数和 std::find 函数来处理字符串,但不知道如何删除尾随空格,除非字符串中出现非白人节奏字符。 我在这里发现了一个类似的问题,但没有得到回答。 : https://stackoverflow.com/questions/24265598/delimiter-is-getting-added-at-the-beginning-of-each-line-of-a-delimited-file-whi

谢谢 汝驰

【问题讨论】:

    标签: c++ string iostream


    【解决方案1】:

    如果其他空格可以被单个空格替换,那么您可以读取字符串中的所有单词(std::cin

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-01-03
      • 2011-06-03
      • 2014-10-30
      • 2022-08-14
      • 1970-01-01
      • 2013-03-04
      • 1970-01-01
      相关资源
      最近更新 更多