How about using regular expressions to transform or extract text?

Hi,
I’d like to do a Edit on the string.
How about using regex to remove text?

Original data(In Clipboard)
Department
AA1 Personnel Department
AA2 General Affairs Department
AA3 Public Relations Department
AA4 Legal Department
AA5 Finance Department
AA6 Accounting Department
BB1 Planning Department
BB2 Procurement Division
BB3 Purchasing Division

Office location:XXXXXX
TEL:XXXXXX
Establishment:MM DD, YYYY
Capital:$XXXXXXXX

Text fix image
1.Remove “^(?!([A-Z][A-Z][A-Z]|[A-Z][A-Z][0-9].*))” from all Lines
2.Remove “^(\w{3})\s” from all Lines

Results in(Variables-List)
Personnel Department
General Affairs Department
Public Relations Department
Legal Department
Finance Department
Accounting Department
Planning Department
Procurement Division
Purchasing Division

Isn’t there a good method for that?

Hi @Moriya_akira

You can do it with the combination of Text actions and a Custom script:

  1. After copying the text to clipboard, remove the text after the first “Department” and berfore "Office"using Substring Between

  2. Trim Whitespace to remove new line symbols

  3. Remove the required text using Custom action

@CustomScriptAction(

input = ['text_original'],
output = 'text_new'
)

def customScript() {

text_new = text_original.replaceAllByRegex('[A-Z]{2}\\d{1}\\s',"");

}
  1. Split the string in a List.

The result will be a list of departments

I was able to do what I thought.
Thank you!

1 Like