# Nesting project file name into layout in QGIS

Is there any way to automatically take information from the project file name into several boxes on a layout in QGIS?

For example, if I had a file name of "185.005R1 - Geology Map.qgz" how could I split it into separate textboxes, e.g. the Drawing number ("185.005"), the title ("Geology Map"), and the Revision number ("1")?

Use the following expressions. They are based on regular expressions, so will be nice and tolerant of slight differences in format:

For Drawing Number:

regexp_substr(@project_filename,'(.*?)R')


For Revision Number

regexp_substr(@project_filename,'.*?R\\s*(.*?)\\s*-')


Title:

regexp_substr(@project_filename,'-\\s*(.*)\\.')


You can use the project variables @project_basename together with substring in the expression builder if your string has always the same structure. If not you can try it with regex.

Another method which worked using expression is as the following:

For Drawing Number:

regexp_substr( @project_filename ,'\\d+.\\d+')


For Revision Number

regexp_substr( @project_filename ,'\\d{3}.\\d{3}\\D+(\\d+)')


For Title:

regexp_substr( @project_filename ,'- (\\D+).qgz')