Writing a regular expression for fax numbers. Not the same as phone number - numbers

I need help writing a regular expression for a fax number. I need it to be option to have the country code. I need it to allow dashes in the country code.
Country code example:1-264
Fax Number with country code: 1-264 (555)-555-5555
Fax Number with country code: 1-264-(555)-555-5555
Fax Number with country code: 1-264-555-555-5555
either of these are allowed
I am using this in javascript but i just need the expression.
Current Code: ^(+\d{1,5}\s)?(?\d{3})?[\s.-]?\d{3}[\s.-]?\d{4}$

Related

Can I use a combination of SUBSTR() and CHARINDEX() to return a particular line in a body of text?

I am writing a T-SQL function that returns an account number from a block of text. The text is generated by the system, and has 3 colons so I need to try to find a way to use SUBSTR() on the row containing "Account:" and not just the colon itself:
Amount: $10.00
Date: 12/5/2022
Account: Mr. John Doe 83850
What would be the cleanest way to select only the line containing the account number to my function for parsing into an integer?
I'll probably mess this up on my phone but something like this should help:
SUBSTRING(TEXT,(PATINDEX('%ACCOUNT:%',TEXT)+9),LEN(TEXT)-(PATINDEX('%ACCOUNT:%',TEXT)+9))
Edit:
You could find the third line by finding your 3rd carriage return and line feed using char(10)+char(13), but that could look messy going 3 levels deep so I wont attempt it on my phone

Barcode Code128 and Microsoft Word

I'm trying to get barcode Code 128 to work in Microsoft Word. We want e-mail addresses to be converted to a barcode and we're using Code 128 because Code 39 doesn't handle special characters (we have _ in our e-mail addresses).
We want the following data on the label: FirstName LastName and E-mail address (which needs to be the barcode)
I tried using the Code 128 font and the barcode scanner just won't read it. I also tried the following code:
{DISPLAYBARCODE "john_doe#domain.org" CODE128 \h 500}
If I can get this to work, I will be using Mail merge and use the MERGEBARCODE string.
I press CTRL+F9 to get the curly brackets.
What am I doing wrong? BTW, I'm using h 500 to fit the barcode within the label.
Any help/suggestions would be appreciated.
Thanks,
M

contact form 7 input auto formatting phone (###) ###-####

I want to auto format the user input for phone numbers, Tax-id SSN etc.
for example:
Phone Numbers: no matter how the user will enter the phone number it will automatically format the input as (###) ###-####
Tax ID: ##-#########
SSN: ###-##-####
Currency: automatically add $ and , and . Example 54254.12 will be $54,254.12.
if anyone know how to do it or if there is a plugin that can do that please reply.
For he Phone Numbers I would suggest you to use "International Telephone Input for Contact Form 7" exte

number representing text string

A web form collects data on students in a band organization at school. The form data is fed into a google sheet that then populates a merge template and the merged forms are emailed to the recipient. A parent needs to print, sign and turn in the forms. There are hundreds of kids in this band and at registration time when the forms are turned in it is easier to sort all the papers in the stack if you have a short sort number in the corner... Volunteer kids don't apply alphabetization well. I'm trying to create a formula that will give me that sorting number to merge onto the header of each page of the PDF they receive after submitting the form. I want it based on last name and then first name and be able to create that number (in the google sheet) on the fly because the merging happens almost instantly when the user submits the form. Hence, an excel type formula is desired that will result in a number representing the kids name. I'd like for each number to be unique but some names are the same for the first few letters, also some names are only 2 characters long. I tried making A=10, B=11, z=35 etc. (so all are 2 digits) So, using only the first 3 characters, Bob Jones would = 192423112411 - hardly easy to sort the paper at a glance and it doesn't really differentiate between Bob Janes either. 4 digits is preferable. I also looked at =code() formula and it came out with long numbers too. Any advice is appreciated. Thanks!
Side note: What method do spreadsheets use to sort text? Do they weight the characters or what? Before I got the automerge thing to work I assigned each kid in the list a number higher than the one below and lower than above (on the sheet), then did the merge.
One option is to:
sort the name list alphabetically
add a sort number column, and put a =TEXT(row(),"0000") formula to generate a unique ID
on the merge spreadsheet, use a VLOOKUP function to retrieve the unique ID for that specific name.
First off, that wall of text was kind of hard to read through. Please try and do a little formatting so the people trying to help you can easily follow what you're trying to convey.
Personally I would suggest a hyphenated system. First initial of last name converted to a number, followed by a hyphen, followed by the first two letters of their first name converted to numbers.
Bob Jones becomes 11-1956 assuming you differentiate between upper and lower case, or 11-1924 if you convert everything to upper case, which I guess makes more sense.
You could use this VBA function to convert names to a system like that:
Function ConvertToIndex(strInput As String) As String
Dim strLast As String
Dim arrName() As String
Dim strFirst1 As String
Dim strFirst2 As String
arrName = Split(strInput, " ")
strLast = Mid(arrName(1), 1, 1)
strFirst1 = Mid(arrName(0), 1, 1)
strFirst2 = Mid(arrName(0), 2, 1)
ConvertToIndex = Asc(UCase(strLast)) - 55 & "-" & Asc(UCase(strFirst1)) - 55 & Asc(UCase(strFirst2)) - 55
'MsgBox ConvertToIndex
End Function
Thank you Tim, Nutsch and Mad Tech for your responses. I appreciate your input. Sorry the paragraph was so long, I get wordy. Because the members get their merged PDF sheet immediately after submitting I need the number to be based on the name as soon as it's entered, not after the fact; so I was looking for a formula that would reside in the sheet. Interesting VBA function too though. I'll settle for numbering them afterwards, maybe when the sheets are turned in. By then I'll know all who are in the band and can assign numbers like before. Thanks again!

How can I compare international phone numbers in Perl?

Are there any modules that can help me compare phone numbers for equality?
For example, the following three numbers are equivalent (when dialling from the UK)
+44 (0)181 1234123
00441811234123
0181 1234123
Is there a perl module that can tell me this?
The closest I can see on CPAN is Number::Phone which is an active project, and supports UK Phone numbers. It should work for the specific example you give. A few countries are supported.
If you've got phone numbers for other countries things could get more difficult due to local formatting idiosyncrasies.
Supposing that the code you need doesn't exist, and you have to write it yourself, there are two basic operations that you need to do:
Apply context. This is where you take the location of the dialing phone into account. If the call isn't international, you supply the country code; if the call isn't long-distance, you provide an area code, etc. This requires some rules per-locale, of course.
Normalize. Remove meaningless spaces and punctuation, convert the international dialing prefix ("011" in NANPA, "00" in most of the rest of the world, but occasionally many weirder things) to the standard "+".
After completing those two steps properly, all inputs that are actually equivalent numbers should give identical output strings.