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

  • Home
  • SEARCH
  • 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 8150401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:03:23+00:00 2026-06-06T15:03:23+00:00

Hey guys this should be simple, I’m just not seeing it, I would like

  • 0

Hey guys this should be simple, I’m just not seeing it, I would like to create a regex (workable under PERL, Awk, SED / *nix) that will operate after it find a leading Cash ($), the very next Equal (=) and work on what is between either the first instance of double or single quotes to the last instance of double or single quotes.

Let me set up a few examples.

$this = 'operate on some text in here'; # operates between single quotes
$this = "operate on some text in here"; # operates between double quotes
$this = 'operate "on some text" in here'; # operates between single quotes
$this = 'operate \'on some text\' in here'; # operates between outer single quotes

I tried some really bad regex. but just couldn’t get it to match right.

Here’s what I’m inserting it into, in case anyones interested

printf '$request1 = "select * from whatever where this = that and active = 1 order by something asc";\n' |
grep '{regex}' * |
perl -pe 's/select/SELECT/g ; s/from/\n   FROM/g ; s/where/\n      WHERE/g ; s/and/\n      AND/g ; s/order by/\n         ORDER BY/g ; s/asc/ASC/g ; s/desc/DESC/g ;' | ## enter through file with all clauses
awk '{gsub(/\r/,"");printf "%s\n%d",$0,length($0)}' ## take first line convert to whitespace, use on following lines

Thanks guys!

  • 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-06T15:03:27+00:00Added an answer on June 6, 2026 at 3:03 pm

    Script:

    @list = <main::DATA>;
    
    foreach (@list) {
      my @x = /^\s*\$(\S+)\s*=\s*(['"])((?:.(?!\2)|\\\2)*.?)\2\s*;/;
      $x[2] =~ s/\\$x[1]/$x[1]/g; # remove backslash before quote character
      print "$x[0]\t$x[2]\n";
    }
    
    __DATA__
    $this = 'operate on some text in here';     // operates between single quotes
    $this = "operate on some text in here";     // operates between double quotes
    $this = 'operate "on some text" in here';   // operates between single quotes
    $this = 'operate \'on some text\' in here'; // operates between outer single quotes
    

    will give you:

    this   operate on some text in here
    this   operate on some text in here
    this   operate "on some text" in here
    this   operate 'on some text' in here
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hey guys, how can I just achieve this simple layout? I'm hoping the answer
Hey guys, this should be quite simple to answer.... Im using XSB Prolog...trying to
Hey guys I know that this is probably just a simple sql statement but
Hey guys, this is simple but I can't make it workn... blah! I have
Hey guys I'm not sure how to write this in AS3, but basically I
hey guys im working on a task to make my story's links like this
hey guys, i know how to create a simple php file that mails some
Hey guys I'm not sure if I'm going about all this the right way.
Hey guys, I would like to develop a light/laser show editor and simulator, and
Hey guys I'm not sure how to phrase this to get the correct search,

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.