Find and replace

37 views
Skip to first unread message

regis leon

unread,
Apr 8, 2020, 7:40:46 AM4/8/20
to BBEdit Talk
Hello 

on a XML I need to change 

                                    <keyframe time="650593944000/180000000s" value="1"/>
                                    <keyframe time="650599950000/180000000s" value="0"/>
                            


to this


                                    <keyframe time="650593944000/180000000s" value="0.99"/>
                                    <keyframe time="650599950000/180000000s" value="0.01"/>
                              


But I need to keep those values between " " the same for all 

because it can be like this


                                    <keyframe time="650023374000/180000000s" value="1"/>
                                    <keyframe time="650029380000/180000000s" value="0"/>
                          



I'm able to find all those line by

<keyframe time="(\d+)/(\d+)s" value="1"/>\n                                    
<keyframe time="(\d+)/(\d+)s" value="0"/>

but if I try to replace  by                              
                                   
                                    <keyframe time="\1/\2s" value="0.99"/>\n                                  
                                    <keyframe time="\3/\4s" value="0.01"/>

I can't keep those values between " "


Help 

Jean-Christophe Helary

unread,
Apr 8, 2020, 8:06:23 AM4/8/20
to bbe...@googlegroups.com
What about you change

value="1"

into

value="0.99"

and

value="0"

into

value="0.01"

without worrying about the rest ?

Jean-Christophe
> --
> This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "sup...@barebones.com" rather than posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
> ---
> You received this message because you are subscribed to the Google Groups "BBEdit Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to bbedit+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/b639dbdd-a2bb-4cb2-96f9-8b31b681d760%40googlegroups.com.

Jean-Christophe Helary
-----------------------------------------------
http://mac4translators.blogspot.com @brandelune


regis leon

unread,
Apr 8, 2020, 8:46:21 AM4/8/20
to BBEdit Talk
I can have value =1 or value = 0
for another pattern

but I retried the command and it works 

I don't know why didn't works the first time

> To unsubscribe from this group and stop receiving emails from it, send an email to bbe...@googlegroups.com.

GP

unread,
Apr 8, 2020, 5:07:32 PM4/8/20
to BBEdit Talk
Why are you trying to split up the \d+/\d+ capturing? Also, you have to take car with the  "/" character since that can be a regular expression delimiter with the PCRE engine BBEdit uses for regular expression searching. The following regular expression matches your example: 

\s*<keyframe time="(\d+\/\d+)s" value="1"/>\s+<keyframe time="(\d+\/\d+)s" value="0"/>

and the replacement expression:

<keyframe time="\1s" value="0.99"/>\n<keyframe time="\2s" value="0.01"/>\n

performs the desired replacement with the exception of the leading white space on each line. I didn't know whether the white space was just for formatting the posting or actually something needed in your data file.
Reply all
Reply to author
Forward
0 new messages