Hi Chris,

Yes, you're right. I got it working, but for future reference here's what I 
was trying to do...I have many of these elements:

*<work>Macbeth<loc>5.1</loc><loc2>5.1.64</loc2></work>*

Both <loc> and <loc2> contain act/scene/line number info and either one 
other the other is incomplete (the one with two numbers) and I want to keep 
the one that's complete (with three numbers). My objective was to delete 
either <loc> or <loc2> if it had only two numbers in it.

Thanks!


On Saturday, May 22, 2021 at 4:08:36 PM UTC-7 [email protected] wrote:

> On 05/22/2021, at 10:50, severdia <[email protected]> wrote:
>
> I can't seem to figure out a way to find and replace some numbers using 
> Grep. This is what I have.
>
> *<loc>2.2</loc><loc2>2.2.93</loc2>*
>
> I have many cases where there are 3 numbers separated by two periods 
> wrapped in *<loc>* (like this: *<loc>2.2.309</loc>*) as well as the 
> example above with 2 numbers separated by 1 period wrapped in* <loc>*. I 
> want to find where there are only two numbers and delete that *<loc>* 
> element. For example I tried:
>
> ------------------------------
>
> Hey Ron,
>
> Explanations are welcome, but when asking for assistance with data 
> manipulation it's best to provide concrete, real-world data samples *and* the 
> expected results.
>
> Words nearly always include assumptions and opportunities for error.
>
> A good test case (or three) along with the expected result(s) makes it 
> *much* easier for people to experiment and get the job right the first 
> time.
>
> If I'm understanding your task correctly then this should work:
>
> Find:
>
> <loc>(\d+\.\d+)</loc>
>
> Replace:
>
> \1
>
>
> --
> Best Regards,
> Chris
>
>

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "[email protected]" 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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/bb51bbae-3c6b-49e4-a2fa-cd08f6ca39f4n%40googlegroups.com.

Reply via email to