Jump to content



Photo

Expression To Delete Everything In Txt From X To Y ?

xpath

  • Please log in to reply
6 replies to this topic

#1 ATuringtest

ATuringtest

    Advanced Member

  • Members
  • PipPipPip
  • 96 posts
  • OS:Windows 10
  • Total Memory:More Than 9Gb
  • Framework:v4.5+, unsure
  • License:Developer Edition

Posted 08 April 2020 - 05:26 AM

I have a load of txt logs and it comes with some standard bumf at the top like headers but they are not actually headers.

The first word of the doc always starts with "Start" and I want to delete everything inbetween to the word "Status:"  including "Status:"

How would I do that in ubot ?

 

many thanks :)

 



#2 HelloInsomnia

HelloInsomnia

    Advanced Member

  • Moderators
  • 3298 posts
  • OS:Windows 10
  • Total Memory:More Than 9Gb
  • Framework:v4.5+, unsure
  • License:Developer Edition

Posted 08 April 2020 - 10:11 AM

Replace regular expression using:

(?i)^start.+?status


#3 ATuringtest

ATuringtest

    Advanced Member

  • Members
  • PipPipPip
  • 96 posts
  • OS:Windows 10
  • Total Memory:More Than 9Gb
  • Framework:v4.5+, unsure
  • License:Developer Edition

Posted 08 April 2020 - 06:44 PM

Hi Nick , that didn't work for some reason :(

 

Heres my code

 

set(#replaceTitle,$replace regular expression(#texttest,"(?i)^Title:.+?Body:",""),"Global")

 

Here's an example of the text I want to delete Title to Body:

 

Title:
Bald Heads

Word Count:
253

Summary:
Over the ages, baldness has been considered a disease. Lately, it has also been followed as a fashion. However, greater numbers of people still feel that a head covered by hair is always more attractive than a bald one.


Keywords:
Bald, Bald Heads, Bald Women, Bald Men


Article Body:


Edited by ATuringtest, 08 April 2020 - 06:50 PM.


#4 ATuringtest

ATuringtest

    Advanced Member

  • Members
  • PipPipPip
  • 96 posts
  • OS:Windows 10
  • Total Memory:More Than 9Gb
  • Framework:v4.5+, unsure
  • License:Developer Edition

Posted 08 April 2020 - 07:13 PM

So I created a text file and put this in it

 

start

Everything in between

status

 

 

Then used your regular expression replace

 

(?i)^start.+?status

 

set(#texttest,$read file("C:\\Users\\Golden\\Desktop\\test_replace.txt"),"Global")
set(#replaceTitle,$replace regular expression(#texttest,"(?i)^start.+?status"," "),"Global")

 

You would think if your expression is correct it would work ? But it doesn't, I cant explain it?



#5 ATuringtest

ATuringtest

    Advanced Member

  • Members
  • PipPipPip
  • 96 posts
  • OS:Windows 10
  • Total Memory:More Than 9Gb
  • Framework:v4.5+, unsure
  • License:Developer Edition

Posted 08 April 2020 - 09:23 PM

Edit, it worked fine Nick , problem was the amount of new lines, cleaned them up in to a single line and bam !! worked lol :)

 

Thanks



#6 HelloInsomnia

HelloInsomnia

    Advanced Member

  • Moderators
  • 3298 posts
  • OS:Windows 10
  • Total Memory:More Than 9Gb
  • Framework:v4.5+, unsure
  • License:Developer Edition

Posted 09 April 2020 - 12:14 PM

You probably want this then:

set(#article,$replace regular expression("Title:
Bald Heads

Word Count:
253

Summary:
Over the ages, baldness has been considered a disease. Lately, it has also been followed as a fashion. However, greater numbers of people still feel that a head covered by hair is always more attractive than a bald one.


Keywords:
Bald, Bald Heads, Bald Women, Bald Men


Article Body:
Here is the article...","(?si)^title.+?body:\\n",""),"Global")


#7 ATuringtest

ATuringtest

    Advanced Member

  • Members
  • PipPipPip
  • 96 posts
  • OS:Windows 10
  • Total Memory:More Than 9Gb
  • Framework:v4.5+, unsure
  • License:Developer Edition

Posted 16 April 2020 - 08:14 AM

 

You probably want this then:

set(#article,$replace regular expression("Title:
Bald Heads

Word Count:
253

Summary:
Over the ages, baldness has been considered a disease. Lately, it has also been followed as a fashion. However, greater numbers of people still feel that a head covered by hair is always more attractive than a bald one.


Keywords:
Bald, Bald Heads, Bald Women, Bald Men


Article Body:
Here is the article...","(?si)^title.+?body:\\n",""),"Global")

 

 

Yep that worked a treat mate thanks again :)







Also tagged with one or more of these keywords: xpath

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users