Regular expression for indian train seat numbers - regex

I am trying to figure out appropriate regex for indian train seat numbers. For e.g. S10 43, B4 24 etc. I know different trains have different number of seats and coaches but a general regex will work for me. I was trying something like this:
[A|B|C|S][1-15][1-72]$
But this is not working. I also didn't find link to all types of seats in train. Can anyone help me with this?

[ABCS](?:1[0-5]|[1-9])\s+(?:[1-9]|[1-6][0-9]|7[0-2])$
Limiting to a given number range (1-15 and 1-72) makes it a little more complicated (as above) - it will be a lot simpler if you just accept 1- or 2-digit numbers:
[ABCS]\d\d?\s+\d\d?$
But that will match A99 99 which apparently isn't valid

Related

Regex pattern for minimum currency

I need a regex pattern for minimum currency, in this instance, so a number under $1000.00 cannot be input into the field. only $1000.00 and up to say $9999.00. This is for a DocuSign Template.
Number 1., The one-time transfer amount from the screenshot must be 1000.00 or higher.
Number 2., The monthly selection must be $100.00 or more.
Here is what I currently have to make them input it in Monetary form. I am struggling with adding the currency thresholds/minimums described above.
^[+-]?[0-9]{1,3}(?:,?[0-9]{3})*\.[0-9]{2}$
I am a novice at best so thank you for any help in advance.
I'm thinking you want something along these lines for 100.00 to 9999.99 you would want a different regex per field.
^[1-9]\d{2,3}\.\d{2}$
https://regex101.com/r/K2SnS7/1
Check that out and play with it. You just need to think in a regex manner, what are the values I can have first, probably not zero. So 1 to 9, with between two and three more numbers. Followed by a decimal and any two numbers. Good luck!

Regex to extract UK Currency including £ symbol and Pence (p)

I am fairly new to RegEx and have had a search around online but am unable to find a regex that fits my requirements.
The ultimate aim is to search a string of text and extract the lowest monetary amount, however as the string may contain more than one £amount, then i'm happy for a regex to just extract all monetary values it can find and then I can write a calculation in order to return the lowest amount.
The string may have numbers that are not monetary values / numerous amounts, therefore the regex should always look for a £ symbol first OR it could end with a "p" or "P" to signify pence. For example "I need 2 of these at £10 each and one of those at 50p" - should return 10.00 & 0.50 - I can then calculate that 0.50 is the lowest amount.
As people also write their amounts in various ways, I need the regex to be able to spot different patterns - including the "," for every thousand. All below values should be valid:
£0
£0.00
£0.00p
£0000
£0000.00
£0000.00p
£0,000
£0,000.00
£0,000.00p
0p
Hopefully someone may be able to advise the best way to approach this.
Thanks
This works on your data set:
(?=^£|.*p$)£?\d*(?:,\d{3})*(\.\d{2})?p?
But it may improperly match some edge cases as well because everything is optional...
https://regex101.com/r/WptUn6/3

Excluding % from a Regex number search

I'm attempting to create a Regex that finds only 2-digit integers or numbers with a precision of 2 decimal points.
In the example string at the bottom, I want to find only the following:
21 and 10.50
Using this expression, 100% is getting captured, in addition to the strings I desire to capture:
(\d){1,2}(\.?)([0-9]?[0-9]?){1,2}
I know I need to use ^% somewhere, but I can't figure out where it goes. Any suggestions are greatly appreciated.
Here's my sample string:
Earn Up to $21 Per Hour - Deliver Food with !!
Delivery Drivers work when they want and make great money when they do.
All orders are prepaid, just pick them up and deliver them to hungry diners. No waiting in line or fumbling with receipts and prepaid cards.
It's fast and easy to start working. Get started today.
Apply Now
Why choose ?
More orders than any other takeout platform
100% of our restaurants are official partners
Competitive pay: Per order fee + mileage + tips
We guarantee an hourly minimum of $10.50/hour*
Create your own schedule & work the hours you want
Word boundaries in your regular expression will grant you a bit more control.
Since word boundaries are a bit strict, we need to introduce an OR condition to address both cases which will satisfy your regex.
(\b[\d]{2}\.[\d]{2}\b)|(\b[\d]{2}\b)
Edit: Try this one,
\b[\d]{2}\b(\.[\d]{2})?
The first example has a chance to fail as it is order dependent due to the way it short-circuits. This I believe should address multiple cases properly.
I think this should work:
(?<!\d)((\d+\.\d\d)|(\d\d))(?!%|\d)
Demo (and explanation)
EDIT:
Improved version:
(?<!\d)(\d{1,2}(?:\.\d{1,2})?)(?!%|\d)
Demo (and explanation)
You can try this variant: (\d{1,}|[\d.])\b(?!%)
It uses negative lookahead (?!%) to exclude digits following by % sign.
Details at regex101

Regular Expression catching uk phone number

I trying to create a regular expression to catch the following conditions, but totally failing to get my head around it (Friday) and need a bit of help please?
Trying to capture UK phone numbers starting with area code or no area code, but excluding mobiles.
example: 01316691234 or 6691234 but not any number starting with 07
got this so far ^[0-9]1?(\d{6,11}) but struggling to exclude the 07 numbers.
This is based on the supposition that UK area codes:
start with 0 and are followed by 1 (usual) or 2 (London);
run to 3-5 digits
are followed by a phone number 6-7 digits long
Whilst this seems sound to me, I'm no telecoms anorak so you'll need to modify accordingly if any part of this supposition is wrong:
/^(0[12345689]\d{1,3} ?)?\d{6,7}$/
Either way, it's a bit of a can of worms. Postscodes and phone numbers don't lend themselves well to REGEX; the more tightly you refine it, the more at risk you are from new rules being added tomorrow - e.g. if they launched a new area code starting 03.
Use a negative look ahead to prevent numbers starting with "07" matching:
^(?!07)([0-9]1)?(\d{6,11})

Regular expression for all bank card numbers

I am using a regular expression to match all UK bank card number formats; I have done research and managed to find/amend a regex that covers the majority of formats. However, I have a bit of an edge case where one is not matching and I do not know why, or how to resolve. This is what I am using:
(\b[4|5|6](\d){3}[\s|-]?((\d){4}[\s|-]?){2}(\d){4}\b)|(\b(\d){4}[\s|-]?(\d){6}[\s|-]?(\d){5}\b)
This is an example card number that does not work: 6759000000005
This is an example card number that does work: 675900000000555
Apologies if this is an easy question, I am fairly new to regular expression syntax. Any help to resolve would be greatly appreciated. Thanks.
See here the demo
The regex is (\b[4|5|6]\d{3}[\s-]?(\d{4}[\s-]?){2}\d{1,4}\b)|(\b\d{4}[\s-]?\d{6}[\s-]?\d{5}\b)
I'm not an expert of UK cards, so I can't tell what is the expected format as you did not gave exemples with spaces or hyphens in them...
If you can refine the requirements it's handlable.
A more generic card number validation (without separators, so you'll need to strip them before) would be
\d{6}\d{1,12}\d
As per the requirements of the norm (found nothing on the minimum length of the account identifier):
An ISO/IEC 7812 card number is most commonly 16 digits in length,[1]
and can be up to 19 digits. The structure is as follows:
a six-digit Issuer Identification Number (IIN) (previously called the
"Bank Identification Number" (BIN)) the first digit of which is the
Major Industry Identifier (MII), a variable length (up to 12 digits)
individual account identifier, a single check digit calculated using
the Luhn algorithm.[2]