只是一小段帮助 [英] Just a small piece of help
问题描述
我刚刚编写了一个小程序,从Visual Studio(visual basic)开始,我被困在一个特定的位置。假设有一个文本框(用户输入一些句子)和旁边的标签。现在我想要,如果用户输入这句话:#绿色#叶子的颜色是什么
然后标签应该包含答案绿色,我所能做的就是打印#Green#,整个句子或没有:| ,我应该怎么做,只有#...#中出现的单词/ s出现!! 请尽快帮忙:(
I was just writing a small program to start with Visual Studio (visual basic) , and i am stuck at 1 particular position. Suppose there is 1 text box (in which user enters some sentence) and a label beside it. now i want that if User enters this sentence: "#Green# What is color of the leaf"
Then the label should contain answer Green , All i could do was to print #Green# , the whole sentence or nothing :| , What should i do so that only word/s contained inside #...# appears!! Please help ASAP :(
推荐答案
你好,
我相信您可以在此处找到问题的解决方案:
如何在两个字符之间提取字符串 [ ^ ]
它使用一个正则表达式来查找字符串并将其解压缩。
Hi there,
I believe the solution to your problem can be found here:
How to extract the strings between two characters[^]
It uses a regular expression to find the string and extract it.
您好,
试试这个:
Hi,
Try this:
label1.Text = System.Text.RegularExpressions.Regex.Match(textBox1.Text, "(?<=#)(.+)(?=#)").Value
' change label1 and textBox1 into the names of your label and text box
希望这有帮助。
Hope this helps.
这篇关于只是一小段帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!