Replace sets of numbers in a given position with 0
-
Hello!
I’ve been trying to look for a solution to this problem I have by using Regular Expressions, but I’ve come up empty.
I have a pose file for a 3D model and the line I want to modify looks like this:Hips: 5.5 5.5 2.8 -0.0248 -0.0071 -0.0215 1 1 1
The first three sets of numbers between spaces are rotation, the next three are position and the last three are size. The position sets of numbers can have up to 4 decimal numbers.
What I want to do is replace the position sets of numbers with 0, so I could end up with a line like this:Hips: 5.5 5.5 2.8 0 0 0 1 1 1
Would there be a way to specifically replace the 4th, 5th and 6th set of numbers between spaces with 0?
Big TIA -
Here’s a solution with a very loose spec. It doesn’t care what the contents of the first 4+3=7 fields are, only that they are chunks of text separated by a single space.
Ctl-h
Fi:^(?:(?:.*? ){4})\K((?:.*? ){3})
Re:0 0 0<=== trailing space needed!
Mode=regex; option box uncheckedThen: Replace All
What I want to do is replace the position sets of numbers with 0
You don’t actually state that you want to do this for every occurrence in a file but that’s what I’ve assumed.
-
Here’s an expression with a somewhat tighter spec, in case file contains lines with different starting text you wish to ignore:
^Hips: (?:(?:.*? ){3})\K((?:.*? ){3})We can make it even tighter, such as validating that the other pieces consist of digits, maybe with decimal points, etc.
-
@neil-schipper
Thank you very much! That worked wonderfully!
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login