
RichardW.07861 (Lucidworks) asked a question.
i.e. I'm looking to replace a string such as "Total Billable Hours: 600 hrs", however the actual hrs is different per data source. Is it possible to use wildcards to perform a find and replace to match "Total Billable Hours: * hrs"?
Usecase: Looking to update table information contained in an Atlassian Confluence page based off of a Google Sheet as the datasource.

Hi Richard. The answer should be yes leveraging regex but I've run into some issues with how the regex is functioning and am looking into it. So your "string" Total Billable Hours: 600 hrs should be as simple as \d{3} or \d {1,} to handle 1 more more digits but it is not working as I would expect.
Here's an example demonstrating the problem:
Card 1 - Shows the \d{1,9} (one to nine digits) found a match
Card 2 - Shows \d (single digit) found a match 3 times and replaced each digit with test
Card 3 - Shows \d{1,9} didn't find a match.
I'm inquiring with Engineering but will see if I can figure out a work-around.
Okay. Found a workaround:
This is looking for one more more digits in a row and replacing it with the specified value (in this case a dynamic value being dragged into the replace)
Hi Tim,
Is it possible to append text in front of the regex to look for? The actual string we receive from the key value is actually an xhtml dump of the entire confluence page. Where we need to find specific values and replace with the updated values before dumping the entire xhtml back to confluence to update the page.
A larger snippet of the xhtml dump would look like this:
Total Billable Hours:</strong></p></th><td><p>600 hours (original total in SOW)</p></td></tr><tr><th><p><strong>Total Hours Billed:</strong></p></th><td><p>1000.5 hours</p></td></tr>
Where there are multiple digits in the text and we would need to look for something more along the lines of "Total Billable Hours:</strong></p></th><td><p>600 hours (original total in SOW)</p></td>" and replace only the 600 hours with a new number. The same would need to be done for several other values such as "Total Hours Billed" as well.
I tried building a regex expression to match:
Total Billable Hours:</strong></p></th><td><p>600 hours (original total in SOW)</p></td></tr>
regex:
Total Billable Hours:<\/strong><\/p><\/th><td><p>\d+ hours \(original total in SOW\)<\/p><\/td><\/tr>
Attempting to replace this entire string with a different number of hours resulted in a "500 Invalid regular expression to match against" error.
Because many of the values you are utilizing in the updated string (html table) are regex operators and would need to be escaped. This new example is far more complex than the previous one and will require quite a bit more massaging. If I have time later today I will see what I can come up with.
I'm overthinking it. It's still all non-numbers so the \d+ works just fine.
Hi Tim,
That makes sense, what if there are multiple digits in the string?
Total Billable Hours:</strong></p></th><td><p>600 hours (original total in SOW)</p></td></tr><tr><th><p><strong>Total Hours Billed:</strong></p></th><td><p>1000.5 hours</p></td></tr>
The thought was to replace the "Total Billable Hours: 600" as well as the "Total Hours Billed: 1000.5" with different values. Which is why I'm trying to be more specific with the "look for" section.
Thing is you keep moving the goal posts. To be able to perform string manipulation you need to know what the entire input is going to be. And if it is consistently in the same format you can build out logic to perform the action you want.
Even looking at your new expanded example I can see its incomplete. This first </th> is a close without an opening.
You need to evaluate what the entirety of the input is going to look like. Determine if it is consistent. Then logic out how to make the modifications. Making a logic guess based on the incomplete sample I would likely do something like "Split" it, replace, then concatenate it back together with the updated values.
Apologies if my question is incomplete, I'm pulling data from internal documentation that would need to be scrubbed. This is why snippets are provided.
I did move the goalpost, simply because the documentation was not sufficient to give me the answers I needed to continue. I did however ask the same question about multiple digits 5 days ago, which is why I reiterated it. I'll go ahead and work on this, thanks for the input.
Here is an example of what i mean by doing a split. If you "know" what your input is and you know you can split it into exactly the same positions every time. You can then evaluate the portions you need to evaluate then make the changes then concatenate the whole thing back together. Note: I didn't perform the replaces on the numbers as this was illustrated above.
This is a good example of a flow I would build out as a Helper. Send the input in using Call flow and have it Return the adjusted value back to the Parent flow.