a2k - 快速为你串起大师 [英] a2k - quick one for you string gurus

查看:98
本文介绍了a2k - 快速为你串起大师的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不知道为什么我在这些方面如此无用,因为答案通常很简单

所以我们这里去......


我有一个字符串,最后可以有任意数量的反斜杠。


例如


hello \

hello \\

hello \\\\\\\\\\\\ \\

嗯,你明白了。我怎样才能删除这些斜杠并最终每次都用

''hello''?


tia

Martin

Don''t know why i''m so useless at these when the answer is usually so simple
so here we go...

I have a string that could have any number of backslashes at the end.

e.g

hello\
hello\\
hello\\\\\\\\\\\\\\\\\\\

Well you get the idea. How can I remove those slashes and end up with
''hello'' every time?

tia
Martin

推荐答案

如果在第一个反斜杠后总是只有反斜杠,那么只需在第一个反斜杠之后切掉所有内容。使用Instr找到它,并且左
If there are always only backslashes after the first backslash, then just chop
off everything after the first one. Use Instr to find it, and Left


只保留

只有它之前的部分。


如果可以的话穿插后穿,然后就更难了。你必须使用正则表达式

,或者你可以使用Mid
to keep
only the portion before it.

If there could be backslashed interspersed, then it''s harder. You have to
either use regular expressions, or you can loop from the length of the string
back towards zero using Mid

从字符串

的长度循环回零,并寻找第一个非\字符,然后

使用左
, and looking for the first non-\ character, then
use Left


这篇关于a2k - 快速为你串起大师的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆