How to use regular expression without using the Regex class?

Asked

Viewed 41 times

0

I need to validate the input of values and strings, but I have doubts about how to use without using the Regex class, how can I get the solution?

var CampoExpressao = new Regex(@"[0-9]");

Above has a regular expression example code.

  • That’s like asking how to ride a car without wheels. If you’re not going to use this class, you’ll have to implement all of its logic anyway - and that’s complex enough for a doctoral thesis. So the question is: why don’t you want to use this class?

1 answer

2


Good evening, friend. I think you’re confusing it with Javascript. In Javascript it is possible to create a regular expression only the closed bar pattern

var re = /ab+c/;

or with the Regexp class

var re = new RegExp("ab+c");

Source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions

In the C# language you will always use the Regex class.

For further clarification see Microsoft’s Regular Expressions . NET Guide, which you can find here

Browser other questions tagged

You are not signed in. Login or sign up in order to post.