Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 987821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:32:35+00:00 2026-05-16T05:32:35+00:00

Embedly has a great regex generator with which you can use to verfiy the

  • 0

Embedly has a great regex generator with which you can use to verfiy the correctnes of services urls(http://api.embed.ly/tools/generator). It generates javascript regexes, but unfortunately it does not generate c# regex expressions. As far as I know though, c# uses the same ECMA regex definition, and I should therefore be able to use the in C#

So what I would like to achieve is take the generated regex from the embdly site and just paste it into my c# code.

The javascript regex would look like this:

/http:\/\/(.*youtube\.com\/watch.*|.*\.youtube\.com\/v\/.*|youtu\.be\/.*|.*\.youtube\.com\/user\/.*#.*|.*\.youtube\.com\/.*#.*\/.*|picasaweb\.google\.com.*\/.*\/.*#.*|picasaweb\.google\.com.*\/lh\/photo\/.*|picasaweb\.google\.com.*\/.*\/.*)/i

and should match urls like:

http://picasaweb.google.com/westerek/LadakhDolinaMarkha?feat=featured#5497194022344000402
http://www.youtube.com/watch?v=GVDc1uXda6Y&feature=related

What I have so far is the following:

Regex regex = new Regex(
      "[/http:\\/\\/(.*youtube\\.com\\/watch.*|.*\\.youtube\\.com\\/"+
      "v\\/.*|youtu\\.be\\/.*|.*\\.youtube\\.com\\/user\\/.*#.*|.*\\."+
      "youtube\\.com\\/.*#.*\\/.*|picasaweb\\.google\\.com.*\\/.*\\/"+
      ".*#.*|picasaweb\\.google\\.com.*\\/lh\\/photo\\/.*|picasaweb"+
      "\\.google\\.com.*\\/.*\\/.*)/i]",
    RegexOptions.IgnoreCase
    | RegexOptions.CultureInvariant
    | RegexOptions.IgnorePatternWhitespace
    | RegexOptions.Compiled
    );

.. but this only gives me partial matches..

EDIT:
Solution: Just paste the embedly javascript regex expression into strEmbdlyRegex string in the following snippet.

    string strEmbdlyRegex = @"/http:\/\/(.*youtube\.com\/watch.*|.*\.youtube\.com\/v\/.*|youtu\.be\/.*|.*\.youtube\.com\/user\/.*#.*|.*\.youtube\.com\/.*#.*\/.*)/i";

string strRegx = strEmbdlyRegex.Remove(0, 1);
strRegx = strRegx.Remove(strRegx.IndexOf("("), 1);
strRegx = strRegx.Remove(strRegx.LastIndexOf(")/i"), 3);
strRegx = strRegx + "]";

regex = new Regex(
     strRegx,
    RegexOptions.IgnoreCase
    | RegexOptions.CultureInvariant
    | RegexOptions.ECMAScript
    | RegexOptions.Compiled
    );
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T05:32:36+00:00Added an answer on May 16, 2026 at 5:32 am

    Being a bit more specific with your problem would help, but I appear to have it working (at least with your two test strings). You just need to clean up a few extraneous characters:

    • Convert it to a literal string using the @"" syntax (no escaping backslashes)
    • Remove the [/ from the beginning of the string
    • Remove the \i from the end of the string
    • Remove the ( and ) near the beginning and end of the string

    Also, you probably don’t need the IgnorePatterWhitespace option, and for a simple URL you probably don’t need the CultureInvariant option either.

    Lastly, there is a RegexOptions.ECMAScript option that allows you to pass in a /regex/i and have it be interpreted the same way JavaScript would handle it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the Embedly API with this code: $.embedly('http://www.youtube.com/watch?v=LfamTmY5REw', {maxWidth: 600, elems: $('#element'), success:
jsFiddle Full Code: http://jsfiddle.net/bvmdW/ I used jQuery Embedly to replace YouTube links with thumbnail
I'm working with Embedly and found out that the key I use, and pay
I've been using a modification of embedly's tutorial to embed thumbnails of photos onto
I dynamically generate the title of a video from the embedly API in my
Here's my application.js file. I'm using the jquery-embedly API: $(document).ready(function() { $('a.oembed').embedly({maxWidth:500,'method':'replace'}).bind('embedly-oembed', function(e, oembed){
I'm writing an app with Ruby on Rails, jQuery and the Embedly API. I
The following code works for Vimeo API: function getTitle($id){ $title = unserialize(file_get_contents(http://vimeo.com/api/v2/video/$id.php)); $theTitle=$title[0]['title']; echo
I am using embed.ly API, but when using example code i just get a
I am writing a function which has to get the thumbnail information from a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.