regex - Equivalent of Java's "LookingAt()" in .net? -


There is a reggae function in java that is called "lookupate" which will allow partial matches against the pattern, my The question is:

What is the equivalent of "LookingAt ()"?

I can not use it or use it for keypayer verification, but I want to know about future reference.

I do not think that LookingAt () What is the right model for what you are trying to do? It all anchors the match for the beginning of the input, as if you had used the ^ anchor at the beginning of your code and < Code> find () by name, and which would be trivial to simulate in .NET.

I think what you are trying to do is preventing users from entering invalid data. For example, if a textfield expects a decimal number with two decimal places , Your verification may be regex \ d + \. \ D \ d If a user starts by typing a digit, then regex does not match, but the marks can become part of a valid entry, so that you continue typing them . But if the user type 'Z', then you block it because there is no way that it is part of a valid entry.

In other words, you do not want to know whether the regex string, you want to know whether the string is part of the raggex. One way to do this is by using the hitEnd () method in Java, but I do not think that .net is equal to this. In fact, I do not know any other reggae taste that does that.

But blocking the compression of users in my opinion is inaccurate in my opinion. I like to know them in some other way that their input is invalid. For example, if you display the contents of the text file in red , Or disable the button used to submit that entry (or both). Every time there is a change in the textfield, you check the content against your (full) regex and accordingly update the position and / or button of the area.

Here is the display of hitcode (:

  import java.util.regex. *; Public class test {public static zero principal (string [] args) throws an exception {pattern p = pattern Com ("\\ d + \\. \\ d \\ d"); Mitcher M = P. Metter (""); String [] test = {"5.99", "5", "@"}; (For string: test) {if (m.reset (s) .matches ()) {System.out.println ("full match"); } And if (m.hitEnd ()) {System.out.println ("partial match"); } And {System.out.println ("no matching"); }}}}  

I get a "full match" for the first string, "partial match" for the second, and "no match" for the third.


Comments