RegExp in Angular Tester

Developer
Size
3,618 Kb
Views
22,264

How do I make an regexp in angular tester?

Test Regular Expressions (RegExp) in Angular. What is a regexp in angular tester? How do you make a regexp in angular tester? This script and codes were developed by Robert on 04 September 2022, Sunday.

RegExp in Angular Tester Previews

RegExp in Angular Tester - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>RegExp in Angular Tester</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <link rel='stylesheet prefetch' href='http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css'> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="container"> <div class="row" ng-controller="MainCtrl as main"> <h1 class="text-center">{{main.title}}</h1> <br> <form style ="margin: auto; width: 90%" name="testForm" novalidate> <div class="form-group"> <label>Regular Expression: </label> <input class="form-control" type="text" ng-model="main.regexp" ng-change="main.updateRE()" ng-required="true"/> </div> <h4>8 Sample RegExp(s) you should know (<a href="https://code.tutsplus.com/tutorials/8-regular-expressions-you-should-know--net-6149" target="_blank">Tuts Plus Tutorial</a>):</h4> <ol style="border:1px solid lightgray; border-radius: 5px; height: 290px; overflow-y: scroll;"> <li ng-repeat='sample in main.regExpSamples'><a href="javascript:" ng-click="main.selectRE(sample)"><img class="rePics" ng-src="{{sample.pic}}"/><strong>{{sample.exp}}</strong> - {{sample.desc}}</a></li> </ol> <div class="form-group"> <label>Match Regular Expression: </label> <input class="form-control failTest" type="text" ng-model="main.result" ng-change="main.checkInput()" ng-required="true" ng-class="{passTest:main.passTest}"/> </div> <blockquote>RegExp "<strong class="muted">{{main.regexpat}}</strong>" matches: {{main.resultOfRegEx}}</blockquote> </form> </div> <br /> <blockquote class="blockquote-reverse"> <p>Thank you <a href="https://code.tutsplus.com/tutorials/8-regular-expressions-you-should-know--net-6149" target="_blank">tutsplus.com</a> for this easy learn by example tutorial on Regular Expressions (aka RegExp).</p> <footer><cite title="Source Title">8 Sample Reg Expressions you should know</cite></footer>
</blockquote
</div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src='http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.14/angular.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

RegExp in Angular Tester - Script Codes CSS Codes

a { cursor: pointer; text-decoration: none; color: black;
}
.failTest { background-color: pink; color: black;
}
.passTest { background-color: #00AEEF; color: white;
}
.rePics { margin: 2px; border: 1px solid lightgray; width: 128px;
}
.rePics:hover { width: 300px;
}

RegExp in Angular Tester - Script Codes JS Codes

(function () { angular.module("agentApp",[]) .controller("MainCtrl", MainCtrl) .controller("SampleCtrl", SampleCtrl) .filter("FilterName", FilterName) .directive("DirName", DirName) .factory("FactoryName", FactoryName); function MainCtrl($scope, FactoryName){ FactoryName.get(); this.title = FactoryName.name this.regExpSamples = FactoryName.samples; this.result = ''; this.resultOfRegEx = false; this.regexp = 'ab*c'; this.passTest = false; this.updateRE = function(){ try { this.regex = new RegExp(this.regexp,'i'); this.regexpat = this.regex.toString(); } catch (err) { this.resultOfRegEx = 'RegExp Error (' + err.message + ')'; } } this.checkInput = function(){ this.resultOfRegEx = this.regex.test(this.result); this.passTest = this.resultOfRegEx === true ? true : false; } this.selectRE = function(item){ this.regexp = item.exp; this.updateRE(); } this.updateRE(); } function SampleCtrl(){ } function FilterName(){ return function(){ return; } } function DirName(){ return { restrict: 'EA', template: [ '<a href="" class="myawesomebutton" ng-transclude>', '<i class="icon-ok-sign"></i>', '</a>' ].join(''), link: function ($scope, $element, $attrs) { // DOM manipulation/events here! $element.on('click', function () { $(this).addClass('test'); }); } }; } function FactoryName($http){ var FactoryService = {}; FactoryService.name = "Angular RegExp Tester"; FactoryService.samples = [ {exp: '^[a-z0-9_-]{3,16}$', desc: 'Matching a Username', pic:'https://cdn.tutsplus.com/net/uploads/legacy/404_regularExpressions/images/username.jpg'}, {exp: '^[a-z0-9_-]{6,18}$', desc: 'Matching a Password', pic: 'https://cdn.tutsplus.com/net/uploads/legacy/404_regularExpressions/images/password.jpg'}, {exp: '^#?([a-f0-9]{6}|[a-f0-9]{3})$', desc: 'Matching a Hex Value', pic: 'https://cdn.tutsplus.com/net/uploads/legacy/404_regularExpressions/images/hex-copy.jpg'}, {exp: '^[a-z0-9-]+$', desc: 'Matching a Slug', pic: 'https://cdn.tutsplus.com/net/uploads/legacy/404_regularExpressions/images/slug.jpg'}, {exp: '^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$', desc: 'Matching an Email', pic: 'https://cdn.tutsplus.com/net/uploads/legacy/404_regularExpressions/images/email.jpg'}, {exp: '^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$', desc: 'Matching a URL', pic: 'https://cdn.tutsplus.com/net/uploads/legacy/404_regularExpressions/images/url.jpg'}, {exp: '^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$', desc: 'Matching an IP Address', pic: 'https://cdn.tutsplus.com/net/uploads/legacy/404_regularExpressions/images/ip.jpg'}, {exp: '^<([a-z]+)([^<]+)*(?:>(.*)<\/\1>|\s+\/>)$', desc: 'Matching an HTML Tag', pic: 'https://cdn.tutsplus.com/net/uploads/legacy/404_regularExpressions/images/htmltag.jpg'} ] FactoryService.get = function(){ return FactoryService; } return FactoryService; } // https://docs.angularjs.org/guide/bootstrap Manual Initialization angular.bootstrap(document, ['agentApp']);
})();
RegExp in Angular Tester - Script Codes
RegExp in Angular Tester - Script Codes
Home Page Home
Developer Robert
Username AgentRR007
Uploaded September 04, 2022
Rating 3
Size 3,618 Kb
Views 22,264
Do you need developer help for RegExp in Angular Tester?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Robert (AgentRR007) Script Codes
Create amazing art & images with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!