A UK number looks like this 233.25 .
For a Dutch Number, it looks like this in the Power APP 233,25.
This works for the Power App in the UK but not in Holland, due to the comma for the decimal separator. How can I change this to get it to work? I have tried an OR statement but it does not work . ( ( TextInput.Text,"\d+(.\d{0,2})?") ) - REGEX
If(IsMatch( TextInput.Text,"\d+(.\d{0,2})?"), //justify whether meet the format
Submit(Form1), //submit the form if the result is true
Nodify("wrong format",NotificationType.Warning)) //display Notification if the result is false
You could try to format it yourself. Regardless of what the user inputs.
Left(Value(TextInput.Text),Len(Value(TextInput.Text))-2) & "," & Right(Value(TextInput.Text),2) & "."
Related
Im trying to get the number between '-' and '-' in google sheets but after trying many things I still havent been able to find the solution.
Data record 1
England Premier League
West Ham vs Crystal Palace
2.090 - 3.47 - 3.770
Expected value = 3.47
Data record 2
England League Two
Carlisle vs Scunthorpe
2.830 - 3.15 - 2.820
Expected value = 3.15
Hopefully someone can help me out
Try either of the following
option 1.
=INDEX(IFERROR(REGEXEXTRACT(AE1:AE4," \d+\.\d+ ")*1))
option 2.
=INDEX(IFERROR(REGEXEXTRACT(AE1:AE4,".* - (\d+\.\d+) ")))
(Do adjust the formula according to your ranges and locale)
use:
=INDEX(IFNA(REGEXEXTRACT(A1:A, "- (\d+(?:.\d+)?) -")*1))
I have two dates in cells
A1=05.11.2021 18:16
B1=05.11.2021 20:16
I need to find difference in hours between two dates. Result should be (B1-A1)=2 I can't find an answer on the Internet, I ask for help.
use:
=TEXT((DATE(
REGEXEXTRACT(B1, "\d{4}"),
REGEXEXTRACT(B1, "\.(\d+)\."),
REGEXEXTRACT(B1, "^\d+"))+INDEX(SPLIT(B1, " "),,2))-(DATE(
REGEXEXTRACT(A1, "\d{4}"),
REGEXEXTRACT(A1, "\.(\d+)\."),
REGEXEXTRACT(A1, "^\d+"))+INDEX(SPLIT(A1, " "),,2)), "[h]")
arrayformula:
=INDEX(IFNA(TEXT((DATE(
REGEXEXTRACT(B1:B, "\d{4}"),
REGEXEXTRACT(B1:B, "\.(\d+)\."),
REGEXEXTRACT(B1:B, "^\d+"))+INDEX(SPLIT(B1:B, " "),,2))-(DATE(
REGEXEXTRACT(A1:A, "\d{4}"),
REGEXEXTRACT(A1:A, "\.(\d+)\."),
REGEXEXTRACT(A1:A, "^\d+"))+INDEX(SPLIT(A1:A, " "),,2)), "[h]")))
shorter:
=INDEX(IFERROR(1/(1/(TEXT(
REGEXREPLACE(B1:B, "(\d+).(\d+).(\d{4})", "$2/$1/$3")-
REGEXREPLACE(A1:A, "(\d+).(\d+).(\d{4})", "$2/$1/$3"), "[h]")))))
EDIT:
As what #basic mentioned in the above comment, you can format the cell where your output goes or use text with h for hour difference and [h] for the whole duration in hours (got from Cooper's answer). See usage and difference below:
Text:
=text(B1-A1, "h")
or
=text(B1-A1, "[h]")
Update:
Make sure your Date Times uses proper delimiters. / and - are acceptable (e.g. 5/11/2021 18:16:00 or 5-11-2021 18:16:00). (This depends entirely on your locale.)
If you want to show it having . as delimiter, just use a custom Date Time format and use . as its delimiter.
Using custom format:
Actual value vs Display value:
If you don't want to do any changes to the date time and want to have it as text, then replace them using regexreplace before using them in text.
RegexReplace:
=text(REGEXREPLACE(B1, "\.", "/") - REGEXREPLACE(A1, "\.", "/"), "h")
or
=text(REGEXREPLACE(B1, "\.", "/") - REGEXREPLACE(A1, "\.", "/"), "[h]")
I have a database with string column product_name which has data like:
Vans Classic Slip-On Black & White Checkerboard/ White - veľkosť (US) : 6 (EUR: 38)
Vans Old Skool - čierna - veľkosť (US) : 9.5 (EUR: 42.5)
I am trying to extract the US size...
SELECT REGEXP_SUBSTR("product_name", ...) AS "size"
...with desired output like this.
size
6
9.5
I have tried this, but to no avail
SELECT REGEXP_SUBSTR("product_name", '(US)(\d+)') AS "size"
I need to agree with B001, this might not be the best way of saving your information. However, if you are sure your strings are going to have this format, you could use this regex
\(US\) ?: ?(\d+\.?\d*) \(EUR: ?(\d+\.?\d*)\)
This will match the US shoe size first and then the EUR one.
Here is a visual explaination of the regex
Please note that this regex will match BOTH sizes, I'm not sure which one you prefer
You can test more cases in this regex101
When working in the web UI I had to double slash my slashes. Thus the following worked as you want.
select REGEXP_SUBSTR(str, '\\(US\\)\\s\\:\\s(\\d+\\.?\\d*)',1,1,'i',1)
from values ('Vans Classic Slip-On Black & White Checkerboard/ White - veľkosť (US) : 6 (EUR: 38)'),
('Vans Old Skool - čierna - veľkosť (US) : 9.5 (EUR: 42.5)') v(str);
gives:
REGEXP_SUBSTR(STR, '\\(US\\)\\S\\:\\S(\\D+\\.?\\D*)',1,1,'I',1)
6
9.5
I need to validate mobile number. My need:
The number may start with +8801 or 8801 or 01
The next number can be 1 or 5 or 6 or 7 or 8 or 9
Then there have exact 8 digit.
How can i write the regular expression using this conditions ?
the mobile numbers I tried
+8801811419556
01811419556
8801711419556
01611419556
8801511419556
Should be pretty simple:
^(?:\+?88)?01[15-9]\d{8}$
^ - From start of the string
(?:\+?88)? - optional 88, which may begin in +
01 - mandatory 01
[15-9] - "1 or 5 or 6 or 7 or 8 or 9"
\d{8} - 8 digits
$ - end of the string
Working example: http://rubular.com/r/BvnSXDOYF8
Update 2020
As BTRC approved 2 new prefixes, 013 for Grameenphone and 014 for Banglalink, updated expression for now:
^(?:\+?88)?01[13-9]\d{8}$
You may use either one of given regular expression to validate Bangladeshi mobile number.
Solution 1:
/(^(\+88|0088)?(01){1}[56789]{1}(\d){8})$/
Robi, Grameen Phone, Banglalink, Airtel and Teletalk operator mobile no are allowed.
Solution 2:
/(^(\+8801|8801|01|008801))[1|5-9]{1}(\d){8}$/
Citycell, Robi, Grameen Phone, Banglalink, Airtel and Teletalk operator mobile no are allowed.
Allowed mobile number pattern
+8801812598624
008801812598624
01812598624
01712598624
01919598624
01672598624
01512598624
................
.................
Use the following regular expression and test it if you want on following site quickly
regex pal
[8]*01[15-9]\d{8}
I know, that question was asked long time ago, but i assume that #G. M. Nazmul Hossain want to validate mobile number againt chosen country. I show you, how to do it with free library libphonenumber from Google. It's available for Java, C++ and Javascript, but there're also fork for PHP and, i believe, other languages.
+880 tells me that it's country code for Bangladesh. Let's try to validate example numbers with following code in Javascript:
String bdNumberStr = "8801711419556"
PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance();
try {
//BD is default country code for Bangladesh (used for number without 880 at the begginning)
PhoneNumber bdNumberProto = phoneUtil.parse(bdNumberStr, "BD");
} catch (NumberParseException e) {
System.err.println("NumberParseException was thrown: " + e.toString());
}
boolean isValid = phoneUtil.isValidNumber(bdNumberProto); // returns true
That code will handle also numbers with spaces in it (for example "880 17 11 41 95 56"), or even with 00880 at the beggininng (+ is sometimes replaced with 00).
Try it out yourself on demo page. Validates all of provided examples and even more.
Have a look at libphonenumber at:
https://code.google.com/p/libphonenumber/
Bangladeshi phone number (Citycell, Robi, Grameen Phone, Banglalink, Airtel and Teletalk operators) validation by using regular expression :
$pattern = '/(^(\+8801|8801|01|008801))[1-9]{1}(\d){8}$/';
$BangladeshiPhoneNo = "+8801840001417";
if(preg_match($pattern, $BangladeshiPhoneNo)){
echo "It is a valid Bangladeshi phone number;
}
**Laravel Bangladeshi Phone No validation for (Citycell, Robi, Grameen Phone, Banglalink, Airtel and Teletalk) and start with +88/88 then 01 then 356789 then 8 digit**
public function rules()
{
return [
'mobile' => 'sometimes|regex:/^(?:\+?88)?01[35-9]\d{8}$/',
];
}
public function messages()
{
'mobile.regex' => 'Mobile no should be bd standard',
];
}
Is there any way I can easily check if a string conforms to the SortableDateTimePattern ("s"), or do I need to write a regular expression?
I've got a form where users can input a copyright date (as a string), and these are the allowed formats:
Year: YYYY (eg 1997)
Year and month: YYYY-MM (eg 1997-07)
Complete date: YYYY-MM-DD (eg 1997-07-16)
Complete date plus hours and minutes: YYYY-MM-DDThh:mmTZD (eg 1997-07-16T19:20+01:00)
Complete date plus hours, minutes and seconds: YYYY-MM-DDThh:mm:ssTZD (eg 1997-07-16T19:20:30+01:00)
Complete date plus hours, minutes, seconds and a decimal fraction of a second
YYYY-MM-DDThh:mm:ss.sTZD (eg 1997-07-16T19:20:30.45+01:00)
I don't have much experience of writing regular expressions so if there's an easier way of doing it I'd be very grateful!
Not thoroughly tested and hence not foolproof, but the following seems to work:
var regex:RegExp = /(?<=\s|^)\d{4}(-\d{2}(-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d{2})?)?\+\d{2}:\d{2})?)?)?(?=\s|$)/g;
var test:String = "23 1997 1998-07 1995-07s 1937-04-16 " +
"1970-0716 1993-07-16T19:20+01:01 1979-07-16T19:20+0100 " +
"2997-07-16T19:20:30+01:08 3997-07-16T19:20:30.45+01:00";
var result:Object
while(result = regex.exec(test))
trace(result[0]);
Traced output:
1997
1998-07
1937-04-16
1993-07-16T19:20+01:01
2997-07-16T19:20:30+01:08
3997-07-16T19:20:30.45+01:00
I am using ActionScript here, but the regex should work in most flavors. When implementing it in your language, note that the first and last / are delimiters and the last g stands for global.
I'd split the input field into many (one for year, month, day etc.).
You can use Javscript to advance from one field to the next once full (i.e. once four characters are in the year box, move focus to month) for smoother entry.
You can then validate each field independently and finally construct the complete date string.