The use of regular expressions in JS and Java

Source: Internet
Author: User

1) How to use regular expressions in Angularjs

<input type= "text" ng-model= "Dutycode" ng-focus= "showdutycodetips = True"

Ng-blur= "showdutycodetips = False" ng-pattern= "/^cv[0-9a-z]{5}$/" >

<span ng-init= "showdutycodetips = False" ng-show= "Showdutycodetips"

Style= "color:red" >&nbsp;&nbsp; Responsibility Coding Rules are: cv+5 bit (numeric or uppercase letters) &nbsp;&nbsp;</span>


2) How to use regular expressions in JS

.) Use RegExp to dynamically set regular expressions

if (! New RegExp ("PL" + Param.productclass + "[0-9a-z]{5}"). Test (Param.plancode)) {

Uitips.alert ("Insurance Code rules: pl+2-bit Products Large class code + 5 digits (number or capital letters)");

Return

}

.) The direct use of regular expressions (expressions cannot be pieced together)

var reg =/^pl03[0-9a-z]{5}$/;

Console.log (Reg.test ("pl03aaaaa"));

3) Use regular expressions in Java code

String postfix = "ABCDE"

return Pattern.compile ("[0-9a-z]{5}"). Matcher (Postfix). matches ();


The use of regular expressions in JS and Java

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.