cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ramanan89
Helper III
Helper III

URL Validation

Hi,

I am using this code for validating link in the form

 

    !IsMatch(DataCardValue2.Text, "(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$")

 

also tried

 

"(([\w]+:)?//)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,63}(:[\d]+)?(/([-//+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?"
//)

 

 

But its not validating the SharePoint and Teams link like below,

 

https://name.sharepoint.com/sites/filename/_layouts/15/Doc.aspx?OR=teams&action=edit&sourcedoc={38B53388-9C2E-4D09-964A-813B747F455A}

 

 and

 

https://teams.microsoft.com/l/file/38B54543-9C0E-4D09-964A-813B737F475A?tenantId=258ac4e4-146a-411e-9dc8-79a9e12fd6da&fileType=pptx&objectUrl=https%3A%2F%2Fname.sharepoint.com%2Fsites%2filenamefilenamefilenamefilenamefilenamefilenamefilenamefilename.pptx&baseUrl=https%3A%2F%2Fname.sharepoint.com%2Fsites%2filename-filename&serviceName=teams&threadId=19:5f2346fc521142ccbb22d38d1edeca68@thread.tacv2&groupId=183435fddb-7ef6-7587-a107-6ecbe64353e5

 

 

It says invalid link, anyway to fix this.

Thanks,

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-bofeng-msft
Community Support
Community Support

Hi @ramanan89 :

Please try this code:

 

IsMatch(DataCardValue2.Text, "(?:http(s):\/\/)[\w.-]+(?:\.[\w.-]+)+[\w\-\.,@?^=%&:/~\+#\{\}]*")

 

 Best Regards,

Bof

View solution in original post

3 REPLIES 3
v-bofeng-msft
Community Support
Community Support

Hi @ramanan89 :

Please try this code:

 

IsMatch(DataCardValue2.Text, "(?:http(s):\/\/)[\w.-]+(?:\.[\w.-]+)+[\w\-\.,@?^=%&:/~\+#\{\}]*")

 

 Best Regards,

Bof

This Works... Thank you so much 🙂

I wonder for the Hyperlink in columns list, max character limit is 255 in SharePoint. But for the share link in Teams itself is more than 255 characters.. 😄

This does not work if pasting from a Copy Link dialogue from SharePoint with "x:, w:" and other characters in the link.

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (1,693)