获取两个字符之间的值 [英] get a value between two characters

查看:87
本文介绍了获取两个字符之间的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



i必须写一个函数,它会给出两个字符之间的值。如果表达式是这样的话,那就是

' 'c''+ inputsvalue +''m''然后

它应该返回inputvalue。所以该函数应该取三个参数开始字符,结束字符和值。函数应该总是返回值之间的值我们可以用RegEx来做这件事。



任何人都可以帮我做这个......?

Hi All,

i have to write function which will give the value between two characters.Suppose if the expression is like
''c'' + inputtedvalue + ''m'' then
it should return inputtedvalue .so the function should take three parameters starting character,ending character and value.The function should always return the value between starting and ending characters.Can we use RegEx to do this.

Can anyone pls help me in doing this.....?

推荐答案

你不需要一个正则表达式 - 这会使它变得更加复杂。

You don''t need a regex - that would make it more complex that it needs to be.
private char InRange(char min, char max, char value)
   {
   if (value < min) return min;
   if (value > max) return max;
   return value;
   }

应该这样做,并且比使用正则表达式的等效物更容易理解!

Should do it, and be a lot easier to understand than the equivalent using a Regex!


int op1, op2, op;
  op1 = int.Parse(screentxt.Text.Split('+')[0].ToString());
  op2 = int.Parse(screentxt.Text.Split('+')[1].ToString());
  op = "+"


这篇关于获取两个字符之间的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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