web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How to remove the new ...
Power Automate
Answered

How to remove the new line formed when parsing a text

(0) ShareShare
ReportReport
Posted on by 49

Hello,

 

I'm new to PAD and Regex, and I tried extracting text from a pdf then parsing it so I can get a text of:

 

Article X Section Y

 

I used the regex (?i)article\s?\n?\s\d\d?\s?\n?((?i)section\s?\n?\d\d?)? just in case the full text is separated with a line in the pdf, also in case the X and Y contains more than one digit.

 

The problem is, it seems that the text extracted is separated with a line, so it looks like this:

 

Article

X Section Y

 

I tried replacing the regex \n in the extracted text with %""% to delete the new line but it doesn't seem to work.
Can anyone help?

Thanks in advance.

I have the same question (0)
  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    It should technically work. Can you share a screenshot of your Replace text action? Are you sure you enabled regular expressions? Did you store the result in the same variable?

    -------------------------------------------------------------------------
    If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up.

    I also provide paid consultancy and development services using Power Automate. If you're interested, DM me and we can discuss it.

  • Srini007 Profile Picture
    3,327 Super User 2025 Season 2 on at

    Hi @devinpal 

     

    Can you share the sample pdf which you are trying to extract using the PAD?

    Or the sample text you are able to extract in a notepad also works

     

    If you find this reply helpful, please consider giving it a LIKE AND

    If this reply answers your question or solves your issue, please ACCEPT AS SOLUTION

     

    Thanks,

    Srini

     

     

  • Nived_Nambiar Profile Picture
    18,129 Super User 2025 Season 2 on at

    Hi @devinpal 

     

    Give a try like this ?

     

    Nived_Nambiar_0-1693225292246.png

     

    Replace action

    Nived_Nambiar_1-1693225307476.png

     

    Thanks & Regards,

    Nived N 🚀

    LinkedIn: Nived N's LinkedIn
    YouTube: Nived N's YouTube Channel

    🔍 Found my answer helpful? Please consider marking it as the solution!
    Your appreciation keeps me motivated. Thank you! 🙌

  • devinpal Profile Picture
    49 on at

    Thank you very much for the replies.

    I'm sorry that I can't provide the pdf, but this is basically what was extracted.

     

    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -
    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Article
    X section Y xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -

     

    and this is the result that appears in the window.

    devinpal_1-1693278762913.png

     

    The second and the third works because they're from a single line in the text source, so it's like:

    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Article X section Y xxxxxxxxxxxxxxxxxxxxxx -

     

    Though in the list it's shown as a single line with a strange double spacing.

    devinpal_2-1693278855712.png


    deleting \s deleted the new line apparently:

     

    devinpal_0-1693278588432.png

     

    But I can't seem to fill the results with a space after that, or maybe this is not how replace text works.

    devinpal_3-1693279039222.png

     

     

    devinpal_5-1693279111436.png

     

    I hope this provide enough information, thank you.

  • devinpal Profile Picture
    49 on at

    And this is my attempt on using "Replace \n with %""%", it's not working.

     

    devinpal_0-1693279987943.png

     

    Though it's strange that in the list, a single space is shown instead of the double space shown from previous follow-up. Seems that removing \n actually works but it still doesn't remove the new line.

    devinpal_1-1693280079006.png

     

  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    If you want to replace text with something that is also a regular expression, you should also enable the "Activate escape sequences" toggle on the Replace text action. But what you've shown in the screenshot is not how it works, really. You cannot use full patterns like [A-z] or \d in the "Replace with" field. You can only use placeholders for specific symbols, such as \s for a white space or \t for a tab.

     

    I am still not quite sure what you're trying to accomplish. Seems like you're replacing newlines in a list of text values. Can you please share a screenshot of your flow, so we can get a better idea of what actions you are using and whether they're laid out correctly?

    -------------------------------------------------------------------------
    If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up.

    I also provide paid consultancy and development services using Power Automate. If you're interested, DM me and we can discuss it.

  • devinpal Profile Picture
    49 on at

    So basically what I'm trying to do is to extract all texts with "Article X section Y" in a pdf file.

    I used the regex (?i)article\s?\n?\s\d\d?\s?\n?((?i)section\s?\n?\d\d?)? so:
    1. I get the "Article X section Y" in the pdf file, then save the texts in a list

    2. I can still get the "Article X section Y" text even if there's no spacing (for example ArticleX sectionY), thus the \s?

    3. I can still get the "Article X section Y" text even if there's more than two digits of X and Y's number but less than 3 digits, thus the \d\d?

    4. I can still get the "Article X section Y" text even if there's a new line separating the text, thus the \n?

    But, apparently when the source pdf text is separated by a line, the extracted text is also separated by a line. What I'm trying to accomplish is getting an extracted text that's just one line with the format of "Article X section Y".

     

    So I tried removing \n and \s. Removing \n somehow doesn't work so I tried removing \s, which worked but then all the characters has no space. So, I tried adding space between alphabet and number but I don't know how to do that.

    I hope that explains my intention, thank you.

  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    I got that part. I'm not quite sure about how you're trying to replace the newline. I have already asked you to provide a screenshot of your Replace text action that does not work (for replacing newlines), but you have not provided it. Can you please provide some screenshots of your flow, including the details of the Replace text action, as well as the other actions that manipulate the text?

     

    I'm quite confident it should work with \n, but you may be using it incorrectly. If you show us what you've done (in the form of screenshots), we might be able to pinpoint the problem.

    -------------------------------------------------------------------------
    If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up.

    I also provide paid consultancy and development services using Power Automate. If you're interested, DM me and we can discuss it.

  • devinpal Profile Picture
    49 on at

    Sorry for the trouble, this is what I did to remove the new line.

    devinpal_0-1693290453499.png


    and this is what I did to get the text.

    devinpal_1-1693290768879.png

     

  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    Okay. And then you somehow put it into a list?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard