PyQGIS search and replace text using regexSearch and Replace text in All Fields in QGIS 3Run regexp in PyQGIS script?selecting by attribute and specific value replaceHow to do a spatial search without select() using PyQGIS?New attribute creation using ogr and regexMultiLine field-name label referencing in PyQGIS?Creating and manipulating an HTML frame in QGIS 3.2.0 Print Composer using PyQGISSearch and Replace text in All Fields in QGIS 3Keeping only 7 digit number within field name using ArcGIS Pro field calculator and regex
How to create a template with variable number of type parameters?
Meaning of "educating the ice"
How do you manage to study and have a balance in your life at the same time?
Why does dough containing a small amount of terumah become exempt from challah?
Can Russians naturally pronounce "попал в бесперспективняк"?
To which country did MiGs in Top Gun belong?
Lumix G7: Raw photos only in 1920x1440, no higher res available
Using font to highlight a god's speech in dialogue
Why doesn’t this recursive CTE with a parameter use an index when it does with a literal?
Punishment in pacifist society
Given a specific computer system, is it possible to estimate the actual precise run time of a piece of Assembly code
How would a disabled person earn their living in a medieval-type town?
When do we use "no women" instead of "no woman"?
Why are my split equations aligned to right by default?
In mathematics is there a substitution that is "different" from Vieta's substitution to solve the cubic equation?
How to run a command 1 out of N times in Bash
Why do modes sound so different, although they are basically the same as a mode of another scale?
What is a "fat pointer" in Rust?
Divide Numbers by 0
How were US credit cards verified in-store in the 1980's?
In which directory do I find a specific HTML code of my wordpress page? Some of it seems to be missing after checking all pages
What is the significance of 104%
Would there be balance issues if I allowed opportunity attacks against any creature, not just hostile ones?
Replace a motion-sensor/timer with simple single pole switch
PyQGIS search and replace text using regex
Search and Replace text in All Fields in QGIS 3Run regexp in PyQGIS script?selecting by attribute and specific value replaceHow to do a spatial search without select() using PyQGIS?New attribute creation using ogr and regexMultiLine field-name label referencing in PyQGIS?Creating and manipulating an HTML frame in QGIS 3.2.0 Print Composer using PyQGISSearch and Replace text in All Fields in QGIS 3Keeping only 7 digit number within field name using ArcGIS Pro field calculator and regex
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
This is based on Run regexp in PyQGIS script? and Search and Replace text in All Fields in QGIS 3
I am trying to modify the code to allow more complex replacements using regex but am unsure how to structure the re.sub function
See https://regex101.com/r/OX1W3b/2/ for one example...
1. DIMENSIONS: | ORIGIN: | Position corrected and IL (0) was changed based on RPS: 3482 -230
2. DIMENSIONS: 2 x 1350 RCP | ORIGIN: PCD13180 | Position corrected and IL (0) was changed based on RPS: 1390 -20800/1350RCP
3. DIMENSIONS: 3 x 375 RCP | ORIGIN:
4. DIMENSIONS: | ORIGIN:
5. Review attribution | DIMENSIONS: | ORIGIN:
Where there is no value after DIMENSIONS or ORIGIN it should be deleted so...
1. Position corrected and IL (0) was changed based on RPS: 3482 -230
2. DIMENSIONS: 2 x 1350 RCP | ORIGIN: PCD13180 | Position corrected and IL (0) was changed based on RPS: 1390 -20800/1350RCP
3. DIMENSIONS: 3 x 375 RCP
4.
5. Review attribution
Here's the current code - see line 10 and 33 for the regex based commands.
#Use in QGIS 3 python console
#Search and replace text in all fields of all layers
#Also allows regex use
import re
#Based on https://gis.stackexchange.com/questions/317855/search-and-replace-text-in-all-fields-in-qgis-3
#set text to search for and replace with.
searchText = "DIM"
regexText = ".*(DIMENSIONS: |)"
replaceText = ""
#run on all layers
layers = QgsProject.instance().mapLayers()
for layer_id, layer in layers.items():
i=1
print("Layer: %s" % (layer.name()))
# get data provider
dpr = layer.dataProvider()
for field in layer.fields():
fieldName=field.name()
for feature in layer.getFeatures():
inText = str(feature[fieldName])
# get field index
fieldIndex = layer.fields().indexFromName(fieldName)
#print ("Checking %s" % (inText))
if searchText in inText:
# change inText
print ("%s . REPLACED: %s in %s with %s in column: %s" % (i, searchText, inText, replaceText, fieldName))
#outText = inText.replace(searchText, replaceText)
outText = re.sub(fieldName, regexText, replaceText)
i+=1
# save changes
dpr.changeAttributeValues(feature.id(): fieldIndex: outText)
print ("Completed")
UPDATE when using regexText = ".*(DIMENSIONS: )(| ORIGIN: ?|? ?)"
I think we need to deal with each key (DIMENSIONS:, ORIGIN: etc) without value separately as there are others and it overly complicates the regex. So forget about ORIGIN: and need to look at code that will just clean up DIMENSIONS as per the examples. The same can then be used for ORIGIN once we get it right.
Basically we just need to get rid of the key (DIMENSIONS:) when it doesn't have text after it and before the | seperator. Any text before or after should be retained as per the examples.
I think the issue is in the use of "outText = re.sub(fieldName, regexText, replaceText)" because the value in replaceText should be the capture string from the regex not the string in replaceText.
pyqgis regex
add a comment |
This is based on Run regexp in PyQGIS script? and Search and Replace text in All Fields in QGIS 3
I am trying to modify the code to allow more complex replacements using regex but am unsure how to structure the re.sub function
See https://regex101.com/r/OX1W3b/2/ for one example...
1. DIMENSIONS: | ORIGIN: | Position corrected and IL (0) was changed based on RPS: 3482 -230
2. DIMENSIONS: 2 x 1350 RCP | ORIGIN: PCD13180 | Position corrected and IL (0) was changed based on RPS: 1390 -20800/1350RCP
3. DIMENSIONS: 3 x 375 RCP | ORIGIN:
4. DIMENSIONS: | ORIGIN:
5. Review attribution | DIMENSIONS: | ORIGIN:
Where there is no value after DIMENSIONS or ORIGIN it should be deleted so...
1. Position corrected and IL (0) was changed based on RPS: 3482 -230
2. DIMENSIONS: 2 x 1350 RCP | ORIGIN: PCD13180 | Position corrected and IL (0) was changed based on RPS: 1390 -20800/1350RCP
3. DIMENSIONS: 3 x 375 RCP
4.
5. Review attribution
Here's the current code - see line 10 and 33 for the regex based commands.
#Use in QGIS 3 python console
#Search and replace text in all fields of all layers
#Also allows regex use
import re
#Based on https://gis.stackexchange.com/questions/317855/search-and-replace-text-in-all-fields-in-qgis-3
#set text to search for and replace with.
searchText = "DIM"
regexText = ".*(DIMENSIONS: |)"
replaceText = ""
#run on all layers
layers = QgsProject.instance().mapLayers()
for layer_id, layer in layers.items():
i=1
print("Layer: %s" % (layer.name()))
# get data provider
dpr = layer.dataProvider()
for field in layer.fields():
fieldName=field.name()
for feature in layer.getFeatures():
inText = str(feature[fieldName])
# get field index
fieldIndex = layer.fields().indexFromName(fieldName)
#print ("Checking %s" % (inText))
if searchText in inText:
# change inText
print ("%s . REPLACED: %s in %s with %s in column: %s" % (i, searchText, inText, replaceText, fieldName))
#outText = inText.replace(searchText, replaceText)
outText = re.sub(fieldName, regexText, replaceText)
i+=1
# save changes
dpr.changeAttributeValues(feature.id(): fieldIndex: outText)
print ("Completed")
UPDATE when using regexText = ".*(DIMENSIONS: )(| ORIGIN: ?|? ?)"
I think we need to deal with each key (DIMENSIONS:, ORIGIN: etc) without value separately as there are others and it overly complicates the regex. So forget about ORIGIN: and need to look at code that will just clean up DIMENSIONS as per the examples. The same can then be used for ORIGIN once we get it right.
Basically we just need to get rid of the key (DIMENSIONS:) when it doesn't have text after it and before the | seperator. Any text before or after should be retained as per the examples.
I think the issue is in the use of "outText = re.sub(fieldName, regexText, replaceText)" because the value in replaceText should be the capture string from the regex not the string in replaceText.
pyqgis regex
Basically in field calc it would be something like --- regexp_replace(fieldName, 'RegexPattern','ReplaceText') but not sure what to do in pyQGIS or this purplelinux.co.nz/?p=96
– GeorgeC
Apr 15 at 11:55
add a comment |
This is based on Run regexp in PyQGIS script? and Search and Replace text in All Fields in QGIS 3
I am trying to modify the code to allow more complex replacements using regex but am unsure how to structure the re.sub function
See https://regex101.com/r/OX1W3b/2/ for one example...
1. DIMENSIONS: | ORIGIN: | Position corrected and IL (0) was changed based on RPS: 3482 -230
2. DIMENSIONS: 2 x 1350 RCP | ORIGIN: PCD13180 | Position corrected and IL (0) was changed based on RPS: 1390 -20800/1350RCP
3. DIMENSIONS: 3 x 375 RCP | ORIGIN:
4. DIMENSIONS: | ORIGIN:
5. Review attribution | DIMENSIONS: | ORIGIN:
Where there is no value after DIMENSIONS or ORIGIN it should be deleted so...
1. Position corrected and IL (0) was changed based on RPS: 3482 -230
2. DIMENSIONS: 2 x 1350 RCP | ORIGIN: PCD13180 | Position corrected and IL (0) was changed based on RPS: 1390 -20800/1350RCP
3. DIMENSIONS: 3 x 375 RCP
4.
5. Review attribution
Here's the current code - see line 10 and 33 for the regex based commands.
#Use in QGIS 3 python console
#Search and replace text in all fields of all layers
#Also allows regex use
import re
#Based on https://gis.stackexchange.com/questions/317855/search-and-replace-text-in-all-fields-in-qgis-3
#set text to search for and replace with.
searchText = "DIM"
regexText = ".*(DIMENSIONS: |)"
replaceText = ""
#run on all layers
layers = QgsProject.instance().mapLayers()
for layer_id, layer in layers.items():
i=1
print("Layer: %s" % (layer.name()))
# get data provider
dpr = layer.dataProvider()
for field in layer.fields():
fieldName=field.name()
for feature in layer.getFeatures():
inText = str(feature[fieldName])
# get field index
fieldIndex = layer.fields().indexFromName(fieldName)
#print ("Checking %s" % (inText))
if searchText in inText:
# change inText
print ("%s . REPLACED: %s in %s with %s in column: %s" % (i, searchText, inText, replaceText, fieldName))
#outText = inText.replace(searchText, replaceText)
outText = re.sub(fieldName, regexText, replaceText)
i+=1
# save changes
dpr.changeAttributeValues(feature.id(): fieldIndex: outText)
print ("Completed")
UPDATE when using regexText = ".*(DIMENSIONS: )(| ORIGIN: ?|? ?)"
I think we need to deal with each key (DIMENSIONS:, ORIGIN: etc) without value separately as there are others and it overly complicates the regex. So forget about ORIGIN: and need to look at code that will just clean up DIMENSIONS as per the examples. The same can then be used for ORIGIN once we get it right.
Basically we just need to get rid of the key (DIMENSIONS:) when it doesn't have text after it and before the | seperator. Any text before or after should be retained as per the examples.
I think the issue is in the use of "outText = re.sub(fieldName, regexText, replaceText)" because the value in replaceText should be the capture string from the regex not the string in replaceText.
pyqgis regex
This is based on Run regexp in PyQGIS script? and Search and Replace text in All Fields in QGIS 3
I am trying to modify the code to allow more complex replacements using regex but am unsure how to structure the re.sub function
See https://regex101.com/r/OX1W3b/2/ for one example...
1. DIMENSIONS: | ORIGIN: | Position corrected and IL (0) was changed based on RPS: 3482 -230
2. DIMENSIONS: 2 x 1350 RCP | ORIGIN: PCD13180 | Position corrected and IL (0) was changed based on RPS: 1390 -20800/1350RCP
3. DIMENSIONS: 3 x 375 RCP | ORIGIN:
4. DIMENSIONS: | ORIGIN:
5. Review attribution | DIMENSIONS: | ORIGIN:
Where there is no value after DIMENSIONS or ORIGIN it should be deleted so...
1. Position corrected and IL (0) was changed based on RPS: 3482 -230
2. DIMENSIONS: 2 x 1350 RCP | ORIGIN: PCD13180 | Position corrected and IL (0) was changed based on RPS: 1390 -20800/1350RCP
3. DIMENSIONS: 3 x 375 RCP
4.
5. Review attribution
Here's the current code - see line 10 and 33 for the regex based commands.
#Use in QGIS 3 python console
#Search and replace text in all fields of all layers
#Also allows regex use
import re
#Based on https://gis.stackexchange.com/questions/317855/search-and-replace-text-in-all-fields-in-qgis-3
#set text to search for and replace with.
searchText = "DIM"
regexText = ".*(DIMENSIONS: |)"
replaceText = ""
#run on all layers
layers = QgsProject.instance().mapLayers()
for layer_id, layer in layers.items():
i=1
print("Layer: %s" % (layer.name()))
# get data provider
dpr = layer.dataProvider()
for field in layer.fields():
fieldName=field.name()
for feature in layer.getFeatures():
inText = str(feature[fieldName])
# get field index
fieldIndex = layer.fields().indexFromName(fieldName)
#print ("Checking %s" % (inText))
if searchText in inText:
# change inText
print ("%s . REPLACED: %s in %s with %s in column: %s" % (i, searchText, inText, replaceText, fieldName))
#outText = inText.replace(searchText, replaceText)
outText = re.sub(fieldName, regexText, replaceText)
i+=1
# save changes
dpr.changeAttributeValues(feature.id(): fieldIndex: outText)
print ("Completed")
UPDATE when using regexText = ".*(DIMENSIONS: )(| ORIGIN: ?|? ?)"
I think we need to deal with each key (DIMENSIONS:, ORIGIN: etc) without value separately as there are others and it overly complicates the regex. So forget about ORIGIN: and need to look at code that will just clean up DIMENSIONS as per the examples. The same can then be used for ORIGIN once we get it right.
Basically we just need to get rid of the key (DIMENSIONS:) when it doesn't have text after it and before the | seperator. Any text before or after should be retained as per the examples.
I think the issue is in the use of "outText = re.sub(fieldName, regexText, replaceText)" because the value in replaceText should be the capture string from the regex not the string in replaceText.
pyqgis regex
pyqgis regex
edited Apr 15 at 9:36
GeorgeC
asked Apr 15 at 3:25
GeorgeCGeorgeC
3,3553 gold badges32 silver badges86 bronze badges
3,3553 gold badges32 silver badges86 bronze badges
Basically in field calc it would be something like --- regexp_replace(fieldName, 'RegexPattern','ReplaceText') but not sure what to do in pyQGIS or this purplelinux.co.nz/?p=96
– GeorgeC
Apr 15 at 11:55
add a comment |
Basically in field calc it would be something like --- regexp_replace(fieldName, 'RegexPattern','ReplaceText') but not sure what to do in pyQGIS or this purplelinux.co.nz/?p=96
– GeorgeC
Apr 15 at 11:55
Basically in field calc it would be something like --- regexp_replace(fieldName, 'RegexPattern','ReplaceText') but not sure what to do in pyQGIS or this purplelinux.co.nz/?p=96
– GeorgeC
Apr 15 at 11:55
Basically in field calc it would be something like --- regexp_replace(fieldName, 'RegexPattern','ReplaceText') but not sure what to do in pyQGIS or this purplelinux.co.nz/?p=96
– GeorgeC
Apr 15 at 11:55
add a comment |
1 Answer
1
active
oldest
votes
Try:
((?<=^...)(DIMENSIONS: |))|( | DIMENSIONS: )|( ?|? ORIGIN:$)|( ?ORIGIN: | )
But it's ugly..
thanks I tried but it removed everything when the regex was found... see updated question. I think the issue is the structure of the outtext = re.sub command.
– GeorgeC
Apr 15 at 6:14
Sorry, I updated my original answer - it's pretty ugly but works on regex101.
– Nav
Apr 15 at 6:34
you are right, it does work in regex101 however when you run the script "DIMENSIONS: | ORIGIN: 2010 PureData Survey" comes out as no value rather than "ORIGIN: 2010 PureData Survey" ---- I think the issue is in the use of "outText = re.sub(fieldName, regexText, replaceText)" because the value in replaceText should be the capture string from the regex not the string in replaceText. ALSO can we forget about the origin and focus on getting rid of "DIMENSIONS: " where there is no value before the pipe, as I think this is confusing this example use case...see regex101.com/r/OX1W3b/5
– GeorgeC
Apr 15 at 8:39
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "79"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f318774%2fpyqgis-search-and-replace-text-using-regex%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Try:
((?<=^...)(DIMENSIONS: |))|( | DIMENSIONS: )|( ?|? ORIGIN:$)|( ?ORIGIN: | )
But it's ugly..
thanks I tried but it removed everything when the regex was found... see updated question. I think the issue is the structure of the outtext = re.sub command.
– GeorgeC
Apr 15 at 6:14
Sorry, I updated my original answer - it's pretty ugly but works on regex101.
– Nav
Apr 15 at 6:34
you are right, it does work in regex101 however when you run the script "DIMENSIONS: | ORIGIN: 2010 PureData Survey" comes out as no value rather than "ORIGIN: 2010 PureData Survey" ---- I think the issue is in the use of "outText = re.sub(fieldName, regexText, replaceText)" because the value in replaceText should be the capture string from the regex not the string in replaceText. ALSO can we forget about the origin and focus on getting rid of "DIMENSIONS: " where there is no value before the pipe, as I think this is confusing this example use case...see regex101.com/r/OX1W3b/5
– GeorgeC
Apr 15 at 8:39
add a comment |
Try:
((?<=^...)(DIMENSIONS: |))|( | DIMENSIONS: )|( ?|? ORIGIN:$)|( ?ORIGIN: | )
But it's ugly..
thanks I tried but it removed everything when the regex was found... see updated question. I think the issue is the structure of the outtext = re.sub command.
– GeorgeC
Apr 15 at 6:14
Sorry, I updated my original answer - it's pretty ugly but works on regex101.
– Nav
Apr 15 at 6:34
you are right, it does work in regex101 however when you run the script "DIMENSIONS: | ORIGIN: 2010 PureData Survey" comes out as no value rather than "ORIGIN: 2010 PureData Survey" ---- I think the issue is in the use of "outText = re.sub(fieldName, regexText, replaceText)" because the value in replaceText should be the capture string from the regex not the string in replaceText. ALSO can we forget about the origin and focus on getting rid of "DIMENSIONS: " where there is no value before the pipe, as I think this is confusing this example use case...see regex101.com/r/OX1W3b/5
– GeorgeC
Apr 15 at 8:39
add a comment |
Try:
((?<=^...)(DIMENSIONS: |))|( | DIMENSIONS: )|( ?|? ORIGIN:$)|( ?ORIGIN: | )
But it's ugly..
Try:
((?<=^...)(DIMENSIONS: |))|( | DIMENSIONS: )|( ?|? ORIGIN:$)|( ?ORIGIN: | )
But it's ugly..
edited Apr 15 at 6:33
answered Apr 15 at 3:37
NavNav
663 bronze badges
663 bronze badges
thanks I tried but it removed everything when the regex was found... see updated question. I think the issue is the structure of the outtext = re.sub command.
– GeorgeC
Apr 15 at 6:14
Sorry, I updated my original answer - it's pretty ugly but works on regex101.
– Nav
Apr 15 at 6:34
you are right, it does work in regex101 however when you run the script "DIMENSIONS: | ORIGIN: 2010 PureData Survey" comes out as no value rather than "ORIGIN: 2010 PureData Survey" ---- I think the issue is in the use of "outText = re.sub(fieldName, regexText, replaceText)" because the value in replaceText should be the capture string from the regex not the string in replaceText. ALSO can we forget about the origin and focus on getting rid of "DIMENSIONS: " where there is no value before the pipe, as I think this is confusing this example use case...see regex101.com/r/OX1W3b/5
– GeorgeC
Apr 15 at 8:39
add a comment |
thanks I tried but it removed everything when the regex was found... see updated question. I think the issue is the structure of the outtext = re.sub command.
– GeorgeC
Apr 15 at 6:14
Sorry, I updated my original answer - it's pretty ugly but works on regex101.
– Nav
Apr 15 at 6:34
you are right, it does work in regex101 however when you run the script "DIMENSIONS: | ORIGIN: 2010 PureData Survey" comes out as no value rather than "ORIGIN: 2010 PureData Survey" ---- I think the issue is in the use of "outText = re.sub(fieldName, regexText, replaceText)" because the value in replaceText should be the capture string from the regex not the string in replaceText. ALSO can we forget about the origin and focus on getting rid of "DIMENSIONS: " where there is no value before the pipe, as I think this is confusing this example use case...see regex101.com/r/OX1W3b/5
– GeorgeC
Apr 15 at 8:39
thanks I tried but it removed everything when the regex was found... see updated question. I think the issue is the structure of the outtext = re.sub command.
– GeorgeC
Apr 15 at 6:14
thanks I tried but it removed everything when the regex was found... see updated question. I think the issue is the structure of the outtext = re.sub command.
– GeorgeC
Apr 15 at 6:14
Sorry, I updated my original answer - it's pretty ugly but works on regex101.
– Nav
Apr 15 at 6:34
Sorry, I updated my original answer - it's pretty ugly but works on regex101.
– Nav
Apr 15 at 6:34
you are right, it does work in regex101 however when you run the script "DIMENSIONS: | ORIGIN: 2010 PureData Survey" comes out as no value rather than "ORIGIN: 2010 PureData Survey" ---- I think the issue is in the use of "outText = re.sub(fieldName, regexText, replaceText)" because the value in replaceText should be the capture string from the regex not the string in replaceText. ALSO can we forget about the origin and focus on getting rid of "DIMENSIONS: " where there is no value before the pipe, as I think this is confusing this example use case...see regex101.com/r/OX1W3b/5
– GeorgeC
Apr 15 at 8:39
you are right, it does work in regex101 however when you run the script "DIMENSIONS: | ORIGIN: 2010 PureData Survey" comes out as no value rather than "ORIGIN: 2010 PureData Survey" ---- I think the issue is in the use of "outText = re.sub(fieldName, regexText, replaceText)" because the value in replaceText should be the capture string from the regex not the string in replaceText. ALSO can we forget about the origin and focus on getting rid of "DIMENSIONS: " where there is no value before the pipe, as I think this is confusing this example use case...see regex101.com/r/OX1W3b/5
– GeorgeC
Apr 15 at 8:39
add a comment |
Thanks for contributing an answer to Geographic Information Systems Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f318774%2fpyqgis-search-and-replace-text-using-regex%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Basically in field calc it would be something like --- regexp_replace(fieldName, 'RegexPattern','ReplaceText') but not sure what to do in pyQGIS or this purplelinux.co.nz/?p=96
– GeorgeC
Apr 15 at 11:55