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 6368571
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:41:35+00:00 2026-05-25T00:41:35+00:00

I came across this regular expression in the jQuery source code: … rmozilla =

  • 0

I came across this regular expression in the jQuery source code:

...
rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/,
...

I was wondering why it was rather complicated. I’m especially interested in the reason behind the second part:

(?:.*? rv:([\w.]+))?

I did some research but I could not figure out what this part of the regular expression adds.

(?:)      to match but not capture
.*?       any amount of any character
 rv:      something literal
([\w.]+)  one or more word characters or a dot
?         appear 0 or 1 time

Particularly, that last ? doesn’t make much sense to me. The whole second part matches if there is or is not a substring as defined by that second part. With some trial and error the regular expression does not seem to differ from just:

/(mozilla)/

Could someone shed some light on what the second part of the regular expression is supposed to do? What does it constrain; what string fails that passes /(mozilla)/ or the other way round?

  • 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-25T00:41:35+00:00Added an answer on May 25, 2026 at 12:41 am

    The two regexes would match the same strings, but would store different information in their capturing groups.

    for the string: mozilla asdf rv:sadf

    /(mozilla)(?:.*? rv:([\w.]+))?/
    $0 = 'mozilla asdf rv:sadf'
    $1 = 'mozilla'
    $2 = 'sadf'
    
    /(mozilla)/
    $0 = 'mozilla'
    $1 = 'mozilla'
    $2 = ''
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Came across this handy regular expression utility in Python (I am a beginner in
I came across this in the Python interpreter source code. void PyThread_delete_key_value(int key) {
I came across this plain js ajax upload code (it seems that jquery $.post
Came across this error today. Wondering if anyone can tell me what it means:
I came across this snippet of code on MSDN: entityBuilder.Metadata = @res://*/AdventureWorksModel.csdl| res://*/AdventureWorksModel.ssdl| res://*/AdventureWorksModel.msl;
I came across this code today AsyncInvoke(OnTimeMessageTimer, (object)null, (ElapsedEventArgs)null); Is there anything wrong with
I came across a regular expression library http://laurikari.net/tre/ and also http://hackage.haskell.org/package/regex-tdfa , but I
I came across this great JQuery example of using a slidetoggle. I want to
I came across this line of code in an application I am revising: substr($sometext1
I came across this code today whilst reading Accelerated GWT (Gupta) - page 151

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.