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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:35:35+00:00 2026-06-02T17:35:35+00:00

I am trying to construct a regular expression to detect a keyword in google

  • 0

I am trying to construct a regular expression to detect a keyword in google search string. i.e. a string from google for a search term “amazing car” is

https://www.google.pl/#hl=pl&output=search&sclient=psy-ab&q=amazing+car&oq=amazing+car&aq=f& ... etc

I tried with this regular expression to detect a keyword car:

(google\.).+(&|\?)q=(car)

But this does not seem to work correctly. Am I missing something?
Thank you very much for advice

  • 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-06-02T17:35:36+00:00Added an answer on June 2, 2026 at 5:35 pm

    Your expression would match only if the query started with “car”. If you use “.*” in the group, the greedy .+ will make the “q=” match the “oq=” later in the URL.

    This may work for you:

    (google\.).+(&|\?)q=([^&]*car)
    

    Or, safer though more complex, apply this regexp which will capture the keyword in the only capture group:

    https?://(?:[^/]+\.)?google\.[^/]+/[^?]*[?#](?:.*&)?q=([^&]*)
    

    Or, if your regexp engine doesn’t support, non-capture groups, use this:

    https?://([^/]+\.)?google\.[^/]+/[^?]*[?#](.*&)?q=([^&]*)
    

    and read your keyword in the third group.

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

Sidebar

Related Questions

I'm trying to evaluate a test string against a regular expression I build from
Im trying to construct a regular expression to just match if the length of
I am trying to construct a regular expression that will match the following URL:
I am trying to construct a regular expression that the total number of a's
I'm trying to construct a regular expression that would match a pattern as such:
I am trying to construct a TreeView from a Menu. My Code is like
I'm currently trying to construct a list of bean classes in Java from a
I am trying to write a regular expression in Javascript to match a name
I'm trying to craft a Java regular expression to split strings of the general
I'm trying to come up with a regular expression that can match only characters

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.