开发者

Validate Strings to be of a exact "kind" (java)

开发者 https://www.devze.com 2023-04-11 13:08 出处:网络
My problem is that I cant make my string a valid one, The valid way is this: for example ---> \"DP 3#4\" this is a rule for a game, and i must validate it... I s开发者_开发百科earched for tokenize

My problem is that I cant make my string a valid one,

The valid way is this:

for example ---> "DP 3#4" this is a rule for a game, and i must validate it... I s开发者_开发百科earched for tokenizer, and even saving an array of char type, but after getting the chars in the array, i just can't work with it the way i want to.


Most (though not all) patterns like this can be easily checked using a Regular Expression. Take some time to learn how to build a Regular Expression that will be valid only for the valid pattern you're looking for. Then you should be able to use code like in these examples to check input against that pattern.


Use regular expressions.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号