How to apply custom validation in vue-tel-input - regex

As the title says, what is the process to applying a customValidate regex in vue-tel-input? You can see customValidate as the last item in the list of props. I have a standard setup like in this code sandbox. However, when I add a regex for the phone number to only allow a phone number with digits and a starting "+", the code hangs and kills my browser, customValidate: /^\+\d+$/. Is my formatting correct or is there another approach I should take? Is my regex ok?

Related

Watson Assistant: How to remove unwanted characters from input string

I am creating a chatbot where users need to input their phone. I need to be able to clean the user input string, removing any character that is not numeric. How can I do this in IBM Watson Assistant?
You can use the string functions like those with regular expressions to extract the phone number.
Another, maybe even better, option is to define a pattern-based entity type. The benefit would be that Watson Assistant could identify parts of the input as phone number entity and you could match dialog nodes or slots for it. If that is not found ("else") you could apply the extraction of numbers and try to guess if that is a phone number.
I would advise you handle user input at the client side. In your case, use the key-pressed event and an "If statement" to check that the character is a number (equal or greater than zero). Alternatively you can add the natural language understanding (Easy to configure machine learning service) to Watson Assistant to make it more intelligent. In this case, Watson will be able to know if data is a valid phone number or not.

Regex to differentiate APIs

I need to create a regex to help determine the number the number of times an API is called. We have multiple APIs and this API is of the following format:
/foo/bar/{barId}/id/{id}
The above endpoint also supports query parameters so the following requests would be valid:
/foo/bar/{barId}/id/{id}?start=0&limit=10
The following requests are also valid:
/foo/bar/{barId}/id/{id}/
/foo/bar/{barId}/id/{id}
We also have the following endpoints:
/foo/bar/{barId}/id/type/
/foo/bar/{barId}/id/name/
/foo/bar/{barId}/id/{id}/price
My current regex to extract calls made only to /foo/bar/{barId}/id/{id} looks something like this:
\/foo\/bar\/(.+)\/id\/(?!type|name)(.+)
But the above regex also includes calls made to /foo/bar/{barId}/id/{id}/price endpoint.
I can check if the string after {id}/ isn't price and exclude calls made to price but it isn't a long term solution since if we add another endpoint we may need to update the regex.
Is there a way to filter calls made only to:
/foo/bar/{barId}/id/{id}
/foo/bar/{barId}/id/{id}/
/foo/bar/{barId}/id/{id}?start=0&limit=10
Such that /foo/bar/{barId}/id/{id}/price isn't also pulled in?
\/foo\/bar\/(.+)\/id\/(?!type|name)(.+)
There is something in your RegEx which is the cause to your problem. "(.+)" RegEx code matches every character after it. So replace it with "[^/]" and add the following code "/?(?!.+)". This is working for me.
/foo/bar/([^/]+)/id/(?!type|name)([^/]+)/?(?!.+)

Can't Get Regex To Work in uBot - Extracting Phone Numbers

Got a block of text I'm trying to pull phone numbers out of.
for example:
Phone Numbers
Any phone numbers that Angelo may currently or previously have used
are displayed below. Run a phone report on a particular number for
more information.
(555) 444-5555 (555) 555-7777 Not seeing something? Access additional
data sources. Accessing premium data sources may reveal hard to find
phone numbers like cell phones
the regex code I wrote to extract the numbers is
.?\d{3}.?\s\d{3}.\d{4}
For whatever reason, the results turn back blank and I'm not sure why. I've tested this regex code inside a uBot Expresion Checker and it pulls the phone numbers out as it should. But once I enter it in uBot it pulls nothing.
Any help? Thanks
FIGURED IT OUT:
.*\d3.?\s\d{3,5}.\d{3,5}
for whatever reason uBot wouldn't display the phone numbers correctly until I had the above worked out.

Insert and activate a phone number in a generated word document

I would like to add a phone number to a word document that I generate using the mso api.
In word, when one writes (Tel:00493298402938) and new line, the phone number is activated automatically.
While trying to record the corresponding macro and check the VBA code, it doesn't show the same behavior and the phone number is interpreted as a normal text.
Any helpful source code in VBA, C# or C++ is welcome.
Thanks!
Maybe the following code would be helpful to you?
ThisWorkbook.ActiveSheet.Hyperlinks.Add Range("A1"), "http://stackoverflow.com"
Just instead of the web address you would need the phone number.

How to create Gmail filter searching for text only at start of subject line?

We receive regular automated build messages from Jenkins build servers at work.
It'd be nice to ferret these away into a label, skipping the inbox.
Using a filter is of course the right choice.
The desired identifier is the string [RELEASE] at the beginning of a subject line.
Attempting to specify any of the following regexes causes emails with the string release in any case anywhere in the subject line to be matched:
\[RELEASE\]*
^\[RELEASE\]
^\[RELEASE\]*
^\[RELEASE\].*
From what I've read subsequently, Gmail doesn't have standard regex support, and from experimentation it seems, as with google search, special characters are simply ignored.
I'm therefore looking for a search parameter which can be used, maybe something like atstart:mystring in keeping with their has:, in: notations.
Is there a way to force the match only if it occurs at the start of the line, and only in the case where square brackets are included?
Sincere thanks.
Regex is not on the list of search features, and it was on (more or less, as Better message search functionality (i.e. Wildcard and partial word search)) the list of pre-canned feature requests, so the answer is "you cannot do this via the Gmail web UI" :-(
There are no current Labs features which offer this. SIEVE filters would be another way to do this, that too was not supported, there seems to no longer be any definitive statement on SIEVE support in the Gmail help.
Updated for link rot The pre-canned list of feature requests was, er canned, the original is on archive.org dated 2012, now you just get redirected to a dumbed down page telling you how to give feedback. Lack of SIEVE support was covered in answer 78761 Does Gmail support all IMAP features?, since some time in 2015 that answer silently redirects to the answer about IMAP client configuration, archive.org has a copy dated 2014.
With the current search facility brackets of any form () {} [] are used for grouping, they have no observable effect if there's just one term within. Using (aaa|bbb) and [aaa|bbb] are equivalent and will both find words aaa or bbb. Most other punctuation characters, including \, are treated as a space or a word-separator, + - : and " do have special meaning though, see the help.
As of 2016, only the form "{term1 term2}" is documented for this, and is equivalent to the search "term1 OR term2".
You can do regex searches on your mailbox (within limits) programmatically via Google docs: http://www.labnol.org/internet/advanced-gmail-search/21623/ has source showing how it can be done (copy the document, then Tools > Script Editor to get the complete source).
You could also do this via IMAP as described here:
Python IMAP search for partial subject
and script something to move messages to different folder. The IMAP SEARCH verb only supports substrings, not regex (Gmail search is further limited to complete words, not substrings), further processing of the matches to apply a regex would be needed.
For completeness, one last workaround is: Gmail supports plus addressing, if you can change the destination address to youraddress+jenkinsrelease#gmail.com it will still be sent to your mailbox where you can filter by recipient address. Make sure to filter using the full email address to:youraddress+jenkinsrelease#gmail.com. This is of course more or less the same thing as setting up a dedicated Gmail address for this purpose :-)
Using Google Apps Script, you can use this function to filter email threads by a given regex:
function processInboxEmailSubjects() {
var threads = GmailApp.getInboxThreads();
for (var i = 0; i < threads.length; i++) {
var subject = threads[i].getFirstMessageSubject();
const regex = /^\[RELEASE\]/; //change this to whatever regex you want, this one should cover OP's scenario
let isAtLeast40 = regex.test(subject)
if (isAtLeast40) {
Logger.log(subject);
// Now do what you want to do with the email thread. For example, skip inbox and add an already existing label, like so:
threads[i].moveToArchive().addLabel("customLabel")
}
}
}
As far as I know, unfortunately there isn't a way to trigger this with every new incoming email, so you have to create a time trigger like so (feel free to change it to whatever interval you think best):
function createTrigger(){ //you only need to run this once, then the trigger executes the function every hour in perpetuity
ScriptApp.newTrigger('processInboxEmailSubjects').timeBased().everyHours(1).create();
}
The only option I have found to do this is find some exact wording and put that under the "Has the words" option. Its not the best option, but it works.
I was wondering how to do this myself; it seems Gmail has since silently implemented this feature. I created the following filter:
Matches: subject:([test])
Do this: Skip Inbox
And then I sent a message with the subject
[test] foo
And the message was archived! So it seems all that is necessary is to create a filter for the subject prefix you wish to handle.