Skip to main content

Questions tagged [regular-expression]

A pre-defined set of characters used to match a pattern in a text, e.g. to find or replace certain parts of a textstring

Filter by
Sorted by
Tagged with
0 votes
1 answer
51 views

Regex failure despite valid regex when creating GeoServer Image Mosaic

I'm attempting to create an ImageMosaic on GeoServer with various custom regex files. I am letting GeoServer create a shapefile index for me. I'm using the example GeoTIFFs from this GeoServer ...
MKF's user avatar
  • 669
0 votes
1 answer
44 views

Using regular expressions to select multiple variables for a function in GEE

In GEE I'm using Awesome GEE's ESRI LULC Dataset to map out and mask water areas for the years 2017 to 2022. Due to it being an Image Collection of multiple dynamic years, I had to filter, mosaic, and ...
Needs_Caffeine's user avatar
1 vote
2 answers
60 views

String function to shorten a string value

In QGIS, I'm trying to create a new variable with a short description of a string value of another variable. For example, in the table below, I would like to have: NAMEABB = "US 1" when NAME ...
eagu_999's user avatar
1 vote
0 answers
47 views

QGIS layer filter doesn't work if there is an other condition next to a regexp one

I have layer in qgis. It has an attribute data_count (Integer) and a value (String). When I filer for "value" ~ 'maximum-speed-limit' it works. When I filter for "data_count" > ...
588chm's user avatar
  • 645
1 vote
1 answer
267 views

Replacing spaces between a number and its unit using regexp_replace [duplicate]

In QGIS attributes I have text strings that sometimes include a measurement as part of descriptions, "such as cut at 10 m". In order to make these look nice when presented in multiline fixed ...
Sethinacan's user avatar
  • 2,002
4 votes
2 answers
518 views

Capturing all matches (occurences) with QGIS regular expressions

Problem I use QGIS with the expression function regexp_matches() that returns an array of all strings captured by capturing groups. Regular expressions normally capture only the first match (occurence)...
Babel's user avatar
  • 74.9k
2 votes
1 answer
260 views

Extracting or selecting only 4 digit numbers from attribute field

I have a field, this field has integer numbers, what I need is to find only the 4 digit numbers and select/extract them. I do know a few solutions but they didn’t work out. What exactly I want to do ...
John's user avatar
  • 21
1 vote
0 answers
240 views

Domain in gpkg QGIS

I try to set the field domain for GeoPackage table fields. (description in : see qgis changelog) I want but I can't use glob domain (with regex constraint), I try many syntax in pattern : '[A-Z]' , &...
pasqal's user avatar
  • 558
1 vote
1 answer
73 views

Regex substr - Extracting number after specific text sequence

Couldn't find any solution to a specific sequence. Context: italian cadaster, where plot number is embedded in a table coded in kml, in the "description" field. I want to extract the plot ...
Gilles's user avatar
  • 475
3 votes
1 answer
352 views

Split a text string with each character as an element of an array with QGIS expressions and regular expressions

I want to use QGIS expressions to split up a text string to an array with each element representing one character of the input's string, like: input: mytext -> ouput: [ 'm', 'y', 't', 'e', 'x', 't' ...
Babel's user avatar
  • 74.9k
0 votes
2 answers
225 views

Identify and split data in other languages using QGIS

I have a dataset containing names in both English and other languages and mixed too. Is their any way to remove data containing other than English language? Eg:
Bruno B's user avatar
  • 849
2 votes
2 answers
346 views

Identify and move data containing special characters to a separate column

My dataset contains special characters. I want to identify the data which contains special characters and separate it into a new column. List of special characters : `~!@#$%^&*_{}[]<>?/ ...
Bruno B's user avatar
  • 849
5 votes
1 answer
278 views

Filtering list of data mixed with both full capital letter words and small letter words in QGIS

My dataset contains mixed values of both capital and small letter wordings, e.g. Hello world (contains fully small letter wording 'world') HELLO World (contains fully capital letter wording 'HELLO') ...
Bruno B's user avatar
  • 849
3 votes
2 answers
331 views

Removing data existing in a closed brackets

I have a dataset that contains a number of closed brackets with data. I don't want the data which exists in the brackets. How can I remove that in QGIS? Mcdonalds(Park Avenue) KFC (Park Avenue) ...
Bruno B's user avatar
  • 849
2 votes
4 answers
612 views

Matching backslash with regex in QGIS Field Calculator

I'm attempting to remove a part of string in an attribute column of a shapefile. The part in question is Snapshots\\ from Snapshots\390_measure_1.jpeg. So I want the output to be 390_measure_1.jpeg. ...
enor's user avatar
  • 411
1 vote
1 answer
156 views

Replacements QGIS/Excel

I have a field filled with expressions like these: 'Xm1 to Xm2'; 'Xm2 to Xm1'; 'Xm19 to Xm20' And I also have an imported Excel table with the correspondet text to replace Xm1, Xm2, Xm(n), ..., Xm20. ...
Rui's user avatar
  • 97
5 votes
4 answers
2k views

Removing unwanted data in the cell of the QGIS Attribute table

How can I remove remove data after any special character in the cell using QGIS? E.g.: Valli Amman Mandir, Chettiyakotai I want only Valli Amman Mandir in the cell. The rest should be removed.
Bruno B's user avatar
  • 849
0 votes
0 answers
33 views

Repetitions on regexp_replace [duplicate]

I'm using regexp_replace to replace expressions like 'Xm1 and Xm2'but also 'Xm11 and Xm2' or 'Xm22 and Xm11' with a text i have on a spreadsheet; Basically i want to make a VLOOKUP on Qgis between the ...
Rui's user avatar
  • 97
0 votes
2 answers
276 views

Regexp_replace a number only when appears alone [closed]

I want to use regexp_replace expression to replace some numbers within a expression, but only when this numbers appear alone. For exemple: If have the expression '1 and 2' I want it to replace for 'B3 ...
Rui's user avatar
  • 97
3 votes
3 answers
477 views

Remove symbols from text with field calculator

I'm attempting to remove € symbols from values in the attributes of a geopackage. For example, I have a value 240 123€ that I want to turn into 240 123. I'm using the field calculator to do this. So ...
enor's user avatar
  • 411
5 votes
2 answers
531 views

QGIS Field Calculator - Remove text inside multipe parentheses from a string

On the QGIS Field calculator, I am trying to remove from a string the text that is inside parentheses using regexp_replace. While it is not a problem to remove the text from a string that contains ...
Val P's user avatar
  • 3,908
4 votes
1 answer
434 views

Filter array with a field value

I need to filter filenames (like DJI_0147_3_5.jpg) in an array, and the code below works, but, where you see a 3 in regex, I need instead a field value. In the array output (sourcefile field) we have ...
fausto ugozzoli's user avatar
3 votes
2 answers
143 views

Inserting space between address and cardinal direction in QGIS

I have a shapefile, which is a parcel map. Its table of contents has a column containing the addresses of several buildings. Some of the addresses hold directional information (i.e. n, s, w, e). The ...
Kaveh Ekbia's user avatar
0 votes
1 answer
181 views

QGIS Regex expression label

I'm trying to use regex expression to label my layer in order to show the parcel number. Here is some examples of what i'm looking for : From this "53042A0027/00M002", to "A27M/2" ...
Florian Marlière's user avatar
2 votes
1 answer
93 views

MapInfo SQL Query with Metacharacters?

I have +8 million edge in MapInfo. I want to select character+digit but I can't. I tried querying as [a-z]+[0-9] but failed to use metacharacters in MapInfo. "New York 1. Street" is true. &...
saroman's user avatar
  • 53
4 votes
2 answers
398 views

Allowing only numbers in table field and preventing saving anything else using shapefiles in QGIS

I have a shapefile in which I want to allow only numbers in a table field. For this I have inserted the following expression in Properties > Attribute Form> Constraints (see Screenshot). not ...
Omegon's user avatar
  • 621
3 votes
2 answers
414 views

Replace all but coordinates from a WKT string, including closing bracket ')'

To get a list of coordinates from a polygon and remove unwanted parts from the resulting string, the following expression works fine to remove the string elements 'Polygon', spaces and opening ...
Babel's user avatar
  • 74.9k
5 votes
2 answers
247 views

QGIS defining the nth character where the label could be wrapped

I have the labels, which include a few of the same characters "/". Unfortunately, I cannot simply use the "Wrap on character" option, because it wraps everywhere where this ...
Geographos's user avatar
  • 3,791
2 votes
4 answers
192 views

QGIS regular expression while importing delimited text

I have a CSV file with following format : UTC,Callsign,Position,Altitude 2021-05-11T11:44:38Z,FABCD,"28.084,7.452",500 ... So I can't import with personalized delimiters. I tried to use ...
dmjf08's user avatar
  • 1,313
5 votes
2 answers
906 views

Replacing '.' and '-' in column values with empty space '' in QGIS

I have a shapefile that has a column named "SBL" with string values that contain points (.) and hyphens (-). However, I want to remove these points and hyphens, but so far I haven't been ...
Kaveh Ekbia's user avatar
4 votes
2 answers
952 views

Replace using regular expression in QGIS: how to mask a dot (point)?

In QGIS, I have a string with the pattern (1 character)(1 character)(dot)(number with 1 or more digits). How can I use regexp_replace() to get the number only? I tried regexp_replace('ab.27',('(\\D\\D(...
Babel's user avatar
  • 74.9k
0 votes
1 answer
776 views

Removing repeated commas with ArcGIS Survey123

I have created a form in ArcGIS Survey123. I have several field where you can enter multiple numbers from a select_multiple question. I then want to put all of those numbers into a single string. So I ...
OwlExpression's user avatar
2 votes
1 answer
643 views

Regex to replace English Characters to Arabic by QGIS

I have a challenge to replace English content which comes from AutoCAD annotation to Arabic characters, Arabic fonts for AutoCAD like xarab store Arabic content as English, I just need to replace ...
GIS Man's user avatar
  • 1,123
4 votes
2 answers
1k views

Regular expressions within QGIS expressions: logical operator AND

Context I use QGIS expressions and want to use regular expressions to identify those strings that contain two words. It's easy to identify those features of the field text that contain both QGIS or ...
Babel's user avatar
  • 74.9k
7 votes
1 answer
780 views

Combining two types of conditions to replace strings with regular expressions in QGIS

I have a string with commas at the beginning, at the end and sometimes two or more commas after each other: ,,, as can see at the bottom. I tried to remove the commas in a way to have a comma ...
Babel's user avatar
  • 74.9k
3 votes
1 answer
3k views

Removing part of string from the right in QGIS

I am trying to remove the last piece of my string in QGIS. I want to delete the E10 from the end. I tried both: How to easily edit attribute data using Regular Expressions? regexp_replace("UPRN&...
Geographos's user avatar
  • 3,791
6 votes
3 answers
2k views

Extract left part of field with regexp_substr after two specific charaters

I would like to create a new field on my table with only the part at the end of another field ("stop_name") which contains things as 'STOP_01_1_S1'. I want to extract what is on the right of ...
Arthur's user avatar
  • 863
5 votes
3 answers
392 views

Splitting string with house number in QGIS Field Calculator

I have a string field with housenumber which contains values like: housenumber 5 12 a 15 b 18 c What are the right expressions for the field calculator to write only the number in "field1&...
Enzo Baldini's user avatar
  • 2,385
1 vote
1 answer
475 views

Finding and replacing coordinates in GeoJSON

I have converted kml files to GeoJSON strings. These represent polygons that are often not closed. I want to enforce their closing by searching for the first lat/lon coordinate in the string, checks ...
GIStrees's user avatar
  • 119
9 votes
1 answer
254 views

Regex_replace in the Field Calculator: unexpected duplication of replacement elements

After testing things out for a different question, I found something unexpected about the way regex_replace works in the Field Calculator, compared to PostgreSQL. The suggested insert ends up ...
Encomium's user avatar
  • 3,193
2 votes
0 answers
369 views

Modify coordinate string in parsed KML file [closed]

I am new to Python. I found this code on the internet to parse names and coordinate strings from KML files and write them into a .csv file. Works excellent! However, for my purpose, I need to convert ...
GIStrees's user avatar
  • 119
1 vote
1 answer
5k views

Conditional Question on Survey123 Connect

In ArcGIS Survey123, I want my next question to appear based on to the previous question answer. I tried the expression ${previous_question} = 'true' however I don't seem to get it right. When I ...
Nancy's user avatar
  • 31
3 votes
2 answers
342 views

Replacing HTML links in attribute table Field Calculator in QGIS

I am having trouble doing a simple replace of a string in QGIS attribute table field calculator. My table has a field "tbljoined_link" that contains HTML links like <a href='islands/luzon....
JAT86's user avatar
  • 952
0 votes
1 answer
316 views

Creating integer field from string with characters in QGIS

I am trying to create a new attribute field in a layer that converts a string with characters into an integer. EXAMPLE: 234' -> 234 or 234'* -> 234 Any ideas on how to accomplish this?
sudofizz's user avatar
  • 195
1 vote
2 answers
1k views

Replacing characters using an expression in QGIS

What regular expression can I use to change values in a string field? I need to change the letter B to a symbol - before the digits, and digits with letter F to make positive. Like this:
Ivan M's user avatar
  • 303
7 votes
3 answers
669 views

Expression to replace characters in QGIS Attribute table

I have a string field. Which requests to put the letter F after the number to all positive digits, and the letter B after minus digits and to delete the sign -. Finally, I want a result like this:
Ivan M's user avatar
  • 303
4 votes
2 answers
816 views

Using the field calculator to replace the character in QGIS

How to use the field calculator to replace the character - in part of the values with the character "B" at the end of this value? I also want to replace the other values without symbol - ...
Ivan M's user avatar
  • 303
2 votes
1 answer
100 views

PyQGIS - Regex to Fill New Attribute Value

I have a gpkg with a column called name. I am trying to use PyQGIS to find any of the values in this column that starts with r and then contain e or x. I would then like to update a new column I've ...
Dunuts's user avatar
  • 693
1 vote
1 answer
46 views

Regex for field name at ArcGIS JS API infoTemplate creation

I'm trying to make same dynamic content builder, but I'm not too experienced. This function sets the content for an infoTemplate of a sublayer(arcgisdynamicservice). It works well, if I hardcode the ...
gregi1991's user avatar
  • 103
3 votes
3 answers
2k views

Remove duplicate values in an attribute using regex and fme

I have an FME process that is duplicating some values in an attribute. When I try to use regex in FME to clean it up it is deleting the separator (see screengrab below). Any ideas on how I can change ...
GeorgeC's user avatar
  • 8,298