Forum Archive

Help with Regex in Editorial

scottcoulter

I normally don't ask the Internet to fix my stuff, but I am at a loss this time

This used to work in Editorial, but now it hasn't for a number of months.

I need to join a number of text lines into one. The number of lines various per document.

For example:

this is line one.
this is line two.

becomes

this is line.this is line two.

As I said, this was working some months ago with a Regex workflow that I would edit for number of lines before running it. Now, nothing seems to work,

Here is my broken workflow: link text

Here is some example text: link text

Any assistance would be tremendously appreciated
Thank you

cook

Hi @scottcoulter ...nothing wrong with asking for some help. I have had a lot of help from those on the forum here!

If I understand correctly - you basically want to add the lines in your example like this:

highlight [page 4]: "The POV ascends quickly into the dark night sky, leaving young Rod far behind"
note [page 4]: Digital Matte Painting. ^2

Becomes:

highlight [page 4]: "The POV ascends quickly into the dark night sky, leaving young Rod far behind" note [page 4]: Digital Matte Painting. ^2

So that 'note' line is appended to the 'highlight' line.

Can you try this out? Just make a workflow like this:
1. Get text from document
2. Run Python script
3. Replace text in document

For the Python script try this:

#coding: utf-8
import workflow
import re

action_in = workflow.get_input()

action_out = re.sub('\nnote', ' note', action_in) 
#this does a replace in regex - finding where there is a line break (\n) with note in the next line and replacing it with a space and 'note'

workflow.set_output(action_out)
scottcoulter

Well that worked!

I don't have the skills to mess around in Python, but holy moly, you have saved me dozens of hours of grinding work.

Thank you so much!

cook

@scottcoulter okay cool. Glad to help.