0

I want to support android RTL and want a quick way to add support RTL in a bunch of xml
so essentially what i want is to replace

android:paddingLeft = 10dp  < !-- here 10dp can be anything else -->

with

android:paddingLeft = 10dp
android:paddingStart = 10dp

I have seen multiple examples with grep and sed which can do text replace, but here i need to extra text to be retained and copied in the next line as well..

I am sure i can do this in notepad++ and/or write a simple java code.. but looking for a simple solution.

1 Answer 1

1

Using sed

sed -r 's/(android:paddingLeft(\s*=\s*\w+))/\1\nandroid:paddingStart\2/g' file

regex101 demo for test and explanation

Sign up to request clarification or add additional context in comments.

1 Comment

Ended up doing grep -rl android:.*Left res/ | xargs sed -i -r 's/(android:(.*)Left(\s*=\s*.*))/\1\nandroid:\2Start\3/gm' Liked the regex101 demo, nice site !!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.