Drivers License Regular Expression Not

admin

R/regex: Helping programmers overcome their regular expression obstacles. And I think those were for matching license classes, not license numbers. Karcher hds 500 cd manual.

Pattern matching -- driver's license number validation

Pattern matching -- driver's license number validation

Hello all..
I'm trying to validate driver's license numbers for each state. I'm going to use a hash of patterns. Some states, such as Arkansas, my example below, have more than one possible method.
I'm getting the pattern to match properly on all three possibilities. However, I need to make sure that there isn't extra text at the beginning or ending of the user's input. Otherwise, the validation is useless. For example:
123-45-6789 is correct
123-45-6789extra_text is NOT correct.
I used the ^ and $ symbols. The ^ works fine; extra text at the beginning is disallowed, and it matches properly if there isn't any. The $ sign, however, isn't working for me. No matter what I try I can't get it to match. I have tried adding () around each possibility but that does not work either.
Code is below:

##########################################################
#!/usr/bin/perl
use strict;
#Use a hash for patterns
my %p = ();
#Valid patterns for Arkansas:
# 123456789 (SSN, no hyphens)
# 123-45-6789 (SSN with hyphens)
# 912345678 (9 then 8 digits)
$p{'AR'} = '^[d]{3}[d]{2}[d]{3}$'.
' '.
'^[d]{3}-[d]{2}-[d]{3}$'.
' '.
'^9[d]{8}$';
#Sample driver license number
my $dl = '123456789';
#$match is just a variable that reports YES if a match if found
my $match = ';
#Check for a match
if($dl =~ /$p{'AR'}/) {
$match = 'YES';
}
#Output the driver license number, and whether it matched or not
my $line = sprintf('%-14s %-4s',$dl,$match);
print $line,'n';
#Exit the program
exit;
##########################################################

When I run the program as is I get this output:
123456789
No 'YES' for a match.
Thanks for any help.
Dale
Freeware
Donate
Windows
3.9 MB
186,786

Notepad++ is a free (as in 'free speech' and also as in 'free beer') source code editor and Notepad replacement that supports several languages. Running in the MS Windows environment, its use is governed by GPL License.

Based on the powerful editing component Scintilla, Notepad++ is written in C++ and uses pure Win32 API and STL which ensures a higher execution speed and smaller program size. By optimizing as many routines as possible without losing user friendliness, Notepad++ is trying to reduce the world carbon dioxide emissions. When using less CPU power, the PC can throttle down and reduce power consumption, resulting in a greener environment.

This project is mature. However, there may be still some bugs and missing features that are being worked on. If you have any questions or suggestions about this project, please post them in the forums. Also, if you wish to make a feature request, you can post it there as well. But there's no guarantee that I'll implement your request.

You're encouraged to translate Notepad++ into your native tongue if there's not already a translation present in the Binary Translations page. And if you want, help translating Notepad++ official site into your native tongue would be greatly appreciated.

Features:

  • Syntax Highlighting and Syntax Folding
  • WYSIWYG
  • User Defined Syntax Highlighting
  • Auto-completion
  • Multi-Document
  • Multi-View
  • Regular Expression Search/Replace supported
  • Full Drag ‘N' Drop supported
  • Dynamic position of Views
  • File Status Auto-detection
  • Zoom in and zoom out
  • Multi-Language environment supported
  • Bookmark
  • Brace and Indent guideline Highlighting
  • Macro recording and playback

What's New:Ioxperts webcam driver 1.1.2 beta 3 for mac.

  • Add multi-column marker (multi-line edge) feature.
  • Add dynamical sorting feature for Folder as Workspace.
  • Make MRU tab activate instead of rightmost tab while tab closure (if MRU enabled).
  • Fix folding state lost on the next startup issue.
  • Make Replace-in-Files confirmation dialog modal to prevent from crashing.
  • Add support of smart-indenting for Perl and Rust.
  • Make recorded macro (IDC_FINDNEXT & IDC_FINDPREV)retro-compatible up to 7.8.4.

Software similar to Notepad++ 14

  • 49 votes
    Sublime Text is a sophisticated text editor for code, markup and prose. You'll love the slick user interface, extraordinary features and amazing performance.
    • Free to Try
    • Windows/macOS/Linux
  • 26 votes
    Plugin Manager is a plugin for Notepad++ that allows you to install, update and remove plugins from Notepad++. A centrally hosted XML file holds the list of plugins, that the plugin manager downloads and processes against the list of installed plugins.
    • Freeware
    • Windows
  • 29 votes
    The ideal text, HTML and HEX editor, and an advanced PHP, Perl, Java and JavaScript editor for programmers.
    • Free to Try
    • Windows