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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:32:40+00:00 2026-06-02T20:32:40+00:00

Could you help me with a regex to change lines like <string name=Final time>Final

  • 0

Could you help me with a regex to change lines like

<string name="Final time">Final time</string>
<string name="After extra time">After extra time</string>

to lines

<string name="final_time">Final time</string>
<string name="after_extra_time">After extra time</string>

So between double quotations replace space with underscore and make all letters lowercase.

I will use this regex with search/replace in VIM.

  • 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-02T20:32:43+00:00Added an answer on June 2, 2026 at 8:32 pm

    A generic approach:

    :%s/\(<string name="\)\(\u\)\([^" ]\+\) \([^" ]\+\)/\1\l\2\e\3_\4/
    

    This replaces every string @name that

    • starts with an upper case character (\u) and
    • consists of two space-separated words (\([^" ]\+\) \([^" ]\+\)) and
    • replaces it with the corresponding lower-case character (\l\2\e).
    • It also replaces the space with an underscore.

    To make everything in @name lower-case, this could be simplified:

    :%s/\(<string name="\)\([^" ]\+\) \([^" ]\+\)/\1\l\2_\3_\e/
    

    To get rid of multiple spaces, do two steps. First, make the attribute value lower-case:

    :%s/\(<string name="\)\([^"]\+\)/\1\l\2\e/
    

    then, replace every space in the attribute value with an underscore

    :%s/\(<string name="[^"]*\)\@<= /_/g
    

    Note that the \@<= is vim’s way of expressing a positive look-behind assertion.

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

Sidebar

Related Questions

could someone help me with the regex pattern that i could use to match
I wonder if someone could help me figure out how to parse a string
It would be great if someone could help me with a Regex for phone
I am not very good with regex and was wondering if someone could help
I'm really bad at regex and was wondering if anyone could help me with
So I have this regex problem and wondered if anyone could help me out?
As the title says... :) Could you help me to build a regex to
I was hoping someone could help me writing a regex for c++ that matches
Could use some help with Regex searching with NetBeans 7.01's find function. I'm trying
I understand regex broadly but I hoped somebody could help understand this a bit

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.