@@ -536,6 +536,13 @@ static QVariant fcnTitle( const QVariantList& values, QgsFeature* , QgsExpressio
536
536
}
537
537
return QVariant ( elems.join ( " " ) );
538
538
}
539
+
540
+ static QVariant fcnTrim ( const QVariantList& values, QgsFeature* , QgsExpression* parent )
541
+ {
542
+ QString str = getStringValue ( values.at ( 0 ), parent );
543
+ return QVariant ( str.trimmed () );
544
+ }
545
+
539
546
static QVariant fcnLength ( const QVariantList& values, QgsFeature* , QgsExpression* parent )
540
547
{
541
548
QString str = getStringValue ( values.at ( 0 ), parent );
@@ -1316,7 +1323,8 @@ const QStringList &QgsExpression::BuiltinFunctions()
1316
1323
<< " coalesce" << " regexp_match" << " $now" << " age" << " year"
1317
1324
<< " month" << " week" << " day" << " hour"
1318
1325
<< " minute" << " second" << " lower" << " upper"
1319
- << " title" << " length" << " replace" << " regexp_replace" << " regexp_substr"
1326
+ << " title" << " length" << " replace" << " trim"
1327
+ << " regexp_replace" << " regexp_substr"
1320
1328
<< " substr" << " concat" << " strpos" << " left"
1321
1329
<< " right" << " rpad" << " lpad"
1322
1330
<< " format_number" << " format_date"
@@ -1379,6 +1387,7 @@ const QList<QgsExpression::Function*> &QgsExpression::Functions()
1379
1387
<< new StaticFunction ( " lower" , 1 , fcnLower, QObject::tr ( " String" ) )
1380
1388
<< new StaticFunction ( " upper" , 1 , fcnUpper, QObject::tr ( " String" ) )
1381
1389
<< new StaticFunction ( " title" , 1 , fcnTitle, QObject::tr ( " String" ) )
1390
+ << new StaticFunction ( " trim" , 1 , fcnTrim, QObject::tr ( " String" ) )
1382
1391
<< new StaticFunction ( " length" , 1 , fcnLength, QObject::tr ( " String" ) )
1383
1392
<< new StaticFunction ( " replace" , 3 , fcnReplace, QObject::tr ( " String" ) )
1384
1393
<< new StaticFunction ( " regexp_replace" , 3 , fcnRegexpReplace, QObject::tr ( " String" ) )
0 commit comments