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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:35:51+00:00 2026-05-28T07:35:51+00:00

The following is a sample of a file I’m editing in vim cutAct =

  • 0

The following is a sample of a file I’m editing in vim

cutAct = new QAction( tr( "Cut" ) );
cutAct->setShortcut( QKeySequence::Cut );
cutAct->setStatusTip( tr( "Cut the current selection" ) );
connect( cutAct, SIGNAL( triggered() ), this, SLOT( cut() ) );

I’m trying to use sed from vim’s command pane to convert all instances of cutAct to actionCut, with the intention being to test my expression before using it to carry out similar conversions on other elements of my code that have a <someString>Act name, so that they all instead follow a action<SomeString> naming convention. So basically:

  1. Start with cutAct
  2. Cut it in half before the ‘Act’ part, so it is cut and Act
  3. Upper-case the ‘c’ in cut so I have ‘Cut’ and ‘Act’
  4. Drop the ‘Act’ and replace it with ‘action’ prepended to the front of ‘Cut’.

This is an example of what I’m after

actionCut = new QAction( tr( "Cut" ) );
actionCut->setShortcut( QKeySequence::Cut );
actionCut->setStatusTip( tr( "Cut the current selection" ) );
connect( actionCut, SIGNAL( triggered() ), this, SLOT( cut() ) )

and I’m trying to use the following command to do it

s_[a-z]\(.*\)Act_action\u\1_g

but what I’m getting out is this

actionUtAct = new Qion( tr( "Cu&t" ), this );
actionUt->setShortcut( QKeySequence::Cut );
actionUt->setStatusTip( tr( "Cut the current selection" ) );
actionOnnect( cut, SIGNAL( triggered() ), diaryEditor, SLOT( cut() ) );

This is my first attempt at any serious use of regular expressions, and I would have believed that my expression would have returned every string starting with a lower case alpha character and anding in ‘Act’ before removing the Act from the end, making the first character upper-case and prepending ‘action’ to the front, but that clearly isn’t what’s happening.

Can someone please tell me how to modify my expression to achieve what I’m after?

  • 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-28T07:35:52+00:00Added an answer on May 28, 2026 at 7:35 am

    In your example:

    c*utAct = new QAct*ion( tr( “Cut” ) );

    group 1 in the regular expression matches the part in italic. The initial [a-z] is outside the parentheses, and regular expressions are greedy, so .* followed by Act will match the last “Act” in the string, not the first.

    Try this: s_\([a-z]\w*\)Act_action\u\1_g

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

Sidebar

Related Questions

I have a sample file like the following: CREATE GLOBAL TEMPORARY TABLE tt_temp_user_11 (
i came across a sample gdbinit file, which was having following statements. can anyone
Looking to parse the following text file: Sample text file: <2008-10-07>text entered by user<Ted
I've an xml file(Sample.xml) which has the following structure <Root> <Child ChildName=Ms_7> <MissingSiblings> <Sibling
I've an xml file (Sample.xml) which has the following structure <RootElement> <Children> <Child Name=FirstChild
Considering the following sample XAML file, which shows the first 1000 people of Facebook,
I have a csv file with following sample data. o-option(alphabetical) v-value(numerical) number1,o1,v1,o2,v2,o3,v3,o4,v4,o5,v5,o6,v6 number2,o1,v11,o2,v22,o3,v33,o44,v44,o5,v55,o6,v66 and
Looking for a way to read the following config file sample using a multi
If I have the following (sample) text file; year,2008,2009,2010 income,1000,1500,2000 dividends,100,200,300 net profit,1100,1700,2300 expenses,500,600,500
The following code sample writes a structure variable of type EMPLOYEE to a file

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.