Reqular Expression issue in Confluence Table Toolbox Macro SQL

Bill Howard
Contributor
December 20, 2024

Hi.  I'm running into an issue with the MATCH_REGEXP function in a Confluence Table Toolbox SQL statement.  

Here's the use case.  I have Confluence table in Confluence with a column that contains a version ID.  The column can contain a number and text.  Here are a few examples of data in this column (bullets not included)

  • 1.0
  • 1.1
  • 1.0.5
  • 2.0
  • Version 1.0
  • 83.5

I want to retrieve just the number from this column and none of the other text.  So I've written the following sql to get the number:

MATCH_REGEXP(T1.'Release Version', "(\d+)(\.\d+)+", "gm") as 'Version Number'

This statement is working fine for the following cases:

  • 1.1
  • 1.0.5
  • Version 1.0
  • 83.5

However, it never works for

  • 1.0
  • 2.0
  • 3.0
  • 4.0
  • 5.0

For some reason, it won't pull a number at all.

I've tested my table, and for the cases here there is just a number like 1.0 or 2.0, if I change the number to 1.1 or 2.1, then the statement works as expected.  It's like there is something specific about just the number formatted as \d.\d that will not work.  Something about it ending in 0?  Is it a bug in the SQL or am I missing something obvious? 

 

1 answer

1 vote
Stiltsoft support
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 20, 2024

Hi @Bill Howard ,

Seems that you are talking about our Table Filter, Charts & Spreadsheets for Confluence app.

The MATCH_REGEXP function works with strings and can sometimes be confused by numbers. Try to adjust your query in the following way:

SELECT *,
MATCH_REGEXP(TEXT(T1.'Release Version'), "(\d+)(\.\d+)+", "gm") as 'Version Number'
FROM T*

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events