NSDataDetector more accuracy (ignore time only) - objective-c

NSDataDetector is very handy to find different types of dates within a string. (e.g. 2015-03-10 or 10. March 15). This is great but how can I tell NSDataDetector to ignore time patterns only (e.g. "Whatever my text is 2:33 and so on"). NSDataDetector recognises this as - TODAY 2:33
In other words: Can I force NSDataDetector to find full dates only ?
Thanks,
Sascha

You would need to run some post processing. Once you have extracted the list of date found. Loop through each result. Locate the original text used to identify the text and check if the text match your format for instance always a year etc. You can then ignore any of the non full date format.
I am actually looking for the same but could not find anything useful directly built by Apple. Then I come up with this idea. Not idea, but should do the job.

Related

What is this date format called?

What is this date format called: 1YYMMDD
Example: 06/28/1959 outputs as 1590628
Example: 06/28/2019 outputs as 1190628
There is always a stinking 1 in front of it, no matter what.
As #TomNash already mentioned in his comment the 1 seems to be a century marker.
So your date format is CYYMMDD where C could be
0 : for 19xx
1 : for 20xx
This kind of format is not part of ISO 8601!
It looks to be a little bit like an IBM special and maybe AS/400 specific solution for the year-2000-problem.
My personal recommendation is to convert such date formats always to ISO 8601 via an intermediate layer before processing them.
Last but not least please remember to set software that use such outdated formats onto a list, because a solution like the century marker has only moved the year-2000-problem 100 years to the future - so the childs of our grandchilds will have the same problem again ...

VB expressions to help search through scraped data in UiPath

I have made a process that reads PDFs and scrapes their text in UiPath. I am struggling to come up with a regular expression that I can use to search for a PO Number. The text that comes from the scrape is fairly unstructured so my best bet is to search for a set of numbers that starts with a 'PO' with no space. For example, "PO1234567890". I will be setting a variable so the system knows that no PO number was found if the string doesn't come up with anything. Any reference material would be welcome as I am a beginner to VB. Thanks!
I have researched and cannot find a way to do the type of search I would like to do.
I expect to be able to search for a "PO1234567890" and no let something like "PO" save. So I somehow need to be able to search for "PO - two digits" and any numbers following without whitespace.
Just try the following:
Dim Regex As System.Text.RegularExpressions.Regex
Regex = New System.Text.RegularExpressions.Regex("PO[0-9]+")
Regex.Matches(SearchString)
The regex string PO[0-9]+ means:
PO followed by at least one number
if you want more digits for example 3... just use PO[0-9]{3}[0-9]* that means:
PO followed by three numbers and as numbers as it can match.
If you need help using regex matches just ask.
Hope it helps!

Cocoa Interface Builder - Number Formatter Bug?

I am trying to put in a range using a Number Formatter component added to a text file. The problem occurs when I input a consistent sequence of number '9'. The field will keep on adding to what is in there ( i .e. 99999999999) up to a 10th number, and then the field will be changed to a random 6 digit number?
Is that a bug with the Number Formatter? Any workarounds?
Also, can I create my own number formatter? That would be the best if a bug does exist I think.
Thanks!
I have tried the same thing on another version of Xcode and it seems to works fine.. Maybe a problem with that version's number formatter..
Thanks for your help.

iRegex for date in user entered textfield

I have an input box and the user can write his DOB(mm/dd/yyyy) into the box.
Before I save the data I like to test for valid input. I am using Regexlite.h and Regexlite.m.I have the regular expression too. I want to compare the regex to the user entered value in text box.But am not knowing how to do it.
Any idea how to test for a valid date? (in .NET I use a simple regex but for the iPhone sdk I am a bit helpless) - but somebody must have been done this before.
Here is a regex you can use to parse it if your looking for something else just leave me a comment
^\d{2}/\d{2}/\d{4}$
I think that you should do more validation than that---you don't want anything happening on 30 February nor allow a birth-year of 1001 and 3001 (time-travellers and Methusaleh's Children can go hang).
Perhaps someone cleverer than I could do this all with regular expressions, but I'd suggest just looking at the string and using some logic.
Why are you not using UIDatePicker to prevent user to enter your own not valid date.

VisualBasic Month function inconsistency

I'm working in a web application using VB.NET. There is also VisualBasic code mixed in it, in particular the Date variable and the Month function of VB.
The problem is this part:
Month("10/01/2008")
On the servers, I get 10 (October) as the month (which is supposed to be correct). On my machine, I get 1 (January) (which is supposed to be wrong).
Two of my colleagues (on their own machines) get different answers, one got 1, the other got 10.
The question is, why is this so?
On my end, I can solve the problem by using .NET's DateTime's Parse (or ParseExact) function to force everything to be "dd/MM/yyyy" format. This works. I'm just wondering why there's an inconsistency.
Extra info: I know the parameter for Month function is supposed to be a Date variable. The code used a string as parameter, and Option Strict was off, and the developers mainly let VB do its own conversion thing. (Legacy code maintenance has a lot of inertia...)
If it helps, the version of Microsoft.VisualBasic.dll on the servers is 7.10.6310.4 (under the Framework folder v1.1.4322). The version on mine (and my 2 colleagues') machine is 7.10.6001.4.
Edit: Regional settings for all machines already set to dd/MM/yyyy format (short date format).
This normally has to do with the regional settings, and more specifically the date/time formats. If you set these formats so that they are all the same on the machines you're testing on, the results should be consistent.
Your idea of using ParseExact is definitely the better solution to go with, IMHO.
This is because the runtime has to convert your given value "10/01/2008" which is indeed a string implicitly to the DateTime datatype.
When converting strings to dates and the other way round, the string format depends on the locale settings of windows.
See this link on msdn.
In this article a way to specify a date literal which is independent of your locale settings:
Just enclose the date with the sign # and specify it in the form mm/dd/yyyy:
So the code
Month(#10/01/2008#)
should give you the answer 10 on any machine.
Ther a two more worarounds given in that msdn article:
1. Use the Format Function with predifned Date/Time Format
To convert a Date literal to the
format of your locale, or to a custom
format, supply the literal to the
Format Function, specifying either
Predefined Date/Time Formats (Format
Function) or User-Defined Date/Time
Formats (Format Function). The
following example demonstrates this.
MsgBox("The formatted date is " &
Format(#5/31/1993#, "dddd, d MMM
yyyy"))
2. Use the DateTime-Class Constructor to construt the right DateTime value
Alternatively, you can use one of the
overloaded constructors of the
DateTime structure to assemble a date
and time value. The following example
creates a value to represent May 31,
1993 at 12:14 in the afternoon.
Dim dateInMay As New
System.DateTime(1993, 5, 31, 12, 14,
0)