jakamaschi Posted April 9, 2024 Posted April 9, 2024 I am trying to use a regular expression on a table to delete a leading space in (nearly) each cell (the first letter are always capitals). But ^\s([A-Z]) does not find anything . Without the caret the spaces are found, but also many desired spaces. Does the caret not work for line/sentence start in tables? Quote
Old Bruce Posted April 9, 2024 Posted April 9, 2024 The caret is for the beginning of a Paragraph. Not necessarily the start of a Line. I would guess that the table is A Paragraph with Line Breaks to start a new row. Quote Mac Pro (Late 2013) Mac OS 12.7.6 Affinity Designer 2.6.0 | Affinity Photo 2.6.0 | Affinity Publisher 2.6.0 | Beta versions as they appear. I have never mastered color management, period, so I cannot help with that.
Staff DWright Posted April 16, 2024 Staff Posted April 16, 2024 Can you please provide more information on where you are entering the expression for your table. Quote
jakamaschi Posted April 16, 2024 Author Posted April 16, 2024 I select the cells of a table column and go to the "Find and Replace" panel (or press <apple-cmd>F). In the options dialog for "Search" I select "Regular expression". It makes no difference which "Regular expression option" is checked or unchecked, especially the "one line mode" option. I have attached a screenshot of my search settings. Unfortunately it does not work to include the options dialog. If the leading caret is removed, the desired but also the unwanted spaces are found. It seems that the beginning of a text in a cell is not recognized as the beginning of a line or paragraph by the regular expression. Quote
bbrother Posted April 18, 2024 Posted April 18, 2024 On 4/16/2024 at 9:44 PM, jakamaschi said: It seems that the beginning of a text in a cell is not recognized as the beginning of a line or paragraph by the regular expression. Hi @jakamaschi, welcome to the forum. Nice of you to join.🙂. Indeed, it does not work as it should and I will clarify a bit, it is caused by an incorrect decision regarding the way of comparing the content of the table (text) with the regular expression pattern, namely treating it as a whole as if we were dealing with one text frame. Hence in case of ^ token we have unexpected results and begining of text in cells is not always recognized as beginning of a line. Why does it work this way with tables? I don't know, you'd have to ask the developer(s) who implemented it. @DWright Can you ask someone who has implemented this why regular expressions are processed this way for a table? @jamakaschi The solution to the problem you briefly described would be to treat each cell separately as an independent text frame, and compare those frames text one by one against regex pattern and show the results in Find and Replace results list. Screenshot of results for [^\s([A-Z])]↓(click to enlarge) Quote
jakamaschi Posted April 20, 2024 Author Posted April 20, 2024 Thank you very much for your comments . This makes the results of the regular expression clear to me. I don't know whether my view is globally correct, but my understanding is that each table cell is a self-contained unit. Is it possible that this will be implemented in the future? But I am afraid that this will be too much effort ... The problem with my text is that I didn't insert the unwanted spaces, I just have to correct them ... 😞 Quote
bbrother Posted April 20, 2024 Posted April 20, 2024 22 hours ago, jakamaschi said: I don't know whether my view is globally correct, but my understanding is that each table cell is a self-contained unit. 22 hours ago, jakamaschi said: Is it possible that this will be implemented in the future? 22 hours ago, jakamaschi said: But I am afraid that this will be too much effort ... Your view coincides with mine, so there are at least two of us now.😉 Whether and when this will be implemented depends on how much this feature is desired. You are the first to notice this, so answer this question yourself. Generally, regular expressions in the Find and Replace panel are an underestimated function, so it is hard to expect that improving it for tables will be a priority. 22 hours ago, jakamaschi said: The problem with my text is that I didn't insert the unwanted spaces, I just have to correct them ... 😞 I know it will be much less pleasant without the ^ token, but you can still fix those unwanted spaces, you just need to use a different strategy, e.g. you can try to target BAD|Bad| BAI| BAE preceded by \s using a pattern like [\s([A-E]{3})] with [Match case] option unchecked. Do not give up @jamakasi The time you spend on finding the right pattern will not be wasted, you will learn more about regular expressions, which will bear fruit in the future💪. Good luck dealing with those unwanted spaces in text, @jamakaschi. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.