PyQGIS search and replace text using regex Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?Search and Replace text in All Fields in QGIS 3Run regexp in PyQGIS script?selecting by attribute and specific value replaceQGIS Updating composer label text via python - problem with Item Properties panelNew attribute creation using ogr and regexLoading same layers every timeHow can I get features that satisfy a QgsExpression using PyQGIS?How can I access a specific button in a toolbar using PyQGIS?Using Python to set text for a label in a QGIS3 print layout labelCreating and manipulating an HTML frame in QGIS 3.2.0 Print Composer using PyQGISElement Tree and RegexSearch and Replace text in All Fields in QGIS 3

Why is my conclusion inconsistent with the van't Hoff equation?

Fundamental Solution of the Pell Equation

What is the meaning of the new sigil in Game of Thrones Season 8 intro?

What's the purpose of writing one's academic biography in the third person?

Do I really need recursive chmod to restrict access to a folder?

Bete Noir -- no dairy

Check which numbers satisfy the condition [A*B*C = A! + B! + C!]

Why is "Consequences inflicted." not a sentence?

In predicate logic, does existential quantification (∃) include universal quantification (∀), i.e. can 'some' imply 'all'?

Error "illegal generic type for instanceof" when using local classes

Can a USB port passively 'listen only'?

What is Wonderstone and are there any references to it pre-1982?

Why was the term "discrete" used in discrete logarithm?

Is it ethical to give a final exam after the professor has quit before teaching the remaining chapters of the course?

How to bypass password on Windows XP account?

Why do people hide their license plates in the EU?

Should I discuss the type of campaign with my players?

Can I cast Passwall to drop an enemy into a 20-foot pit?

What to do with chalk when deepwater soloing?

Abandoning the Ordinary World

Using et al. for a last / senior author rather than for a first author

How come Sam didn't become Lord of Horn Hill?

How to react to hostile behavior from a senior developer?

porting install scripts : can rpm replace apt?



PyQGIS search and replace text using regex



Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?Search and Replace text in All Fields in QGIS 3Run regexp in PyQGIS script?selecting by attribute and specific value replaceQGIS Updating composer label text via python - problem with Item Properties panelNew attribute creation using ogr and regexLoading same layers every timeHow can I get features that satisfy a QgsExpression using PyQGIS?How can I access a specific button in a toolbar using PyQGIS?Using Python to set text for a label in a QGIS3 print layout labelCreating and manipulating an HTML frame in QGIS 3.2.0 Print Composer using PyQGISElement Tree and RegexSearch and Replace text in All Fields in QGIS 3



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








3















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: ?|? ?)"
enter image description here



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.










share|improve this question
























  • 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
    yesterday

















3















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: ?|? ?)"
enter image description here



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.










share|improve this question
























  • 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
    yesterday













3












3








3








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: ?|? ?)"
enter image description here



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.










share|improve this question
















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: ?|? ?)"
enter image description here



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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited yesterday







GeorgeC

















asked 2 days ago









GeorgeCGeorgeC

2,92832981




2,92832981












  • 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
    yesterday

















  • 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
    yesterday
















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
yesterday





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
yesterday










1 Answer
1






active

oldest

votes


















1














Try:



((?<=^...)(DIMENSIONS: |))|( | DIMENSIONS: )|( ?|? ORIGIN:$)|( ?ORIGIN: | )


But it's ugly..






share|improve this answer

























  • 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
    yesterday











  • Sorry, I updated my original answer - it's pretty ugly but works on regex101.

    – Nav
    yesterday












  • 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
    yesterday











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
);



);













draft saved

draft discarded


















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









1














Try:



((?<=^...)(DIMENSIONS: |))|( | DIMENSIONS: )|( ?|? ORIGIN:$)|( ?ORIGIN: | )


But it's ugly..






share|improve this answer

























  • 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
    yesterday











  • Sorry, I updated my original answer - it's pretty ugly but works on regex101.

    – Nav
    yesterday












  • 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
    yesterday















1














Try:



((?<=^...)(DIMENSIONS: |))|( | DIMENSIONS: )|( ?|? ORIGIN:$)|( ?ORIGIN: | )


But it's ugly..






share|improve this answer

























  • 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
    yesterday











  • Sorry, I updated my original answer - it's pretty ugly but works on regex101.

    – Nav
    yesterday












  • 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
    yesterday













1












1








1







Try:



((?<=^...)(DIMENSIONS: |))|( | DIMENSIONS: )|( ?|? ORIGIN:$)|( ?ORIGIN: | )


But it's ugly..






share|improve this answer















Try:



((?<=^...)(DIMENSIONS: |))|( | DIMENSIONS: )|( ?|? ORIGIN:$)|( ?ORIGIN: | )


But it's ugly..







share|improve this answer














share|improve this answer



share|improve this answer








edited yesterday

























answered yesterday









NavNav

663




663












  • 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
    yesterday











  • Sorry, I updated my original answer - it's pretty ugly but works on regex101.

    – Nav
    yesterday












  • 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
    yesterday

















  • 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
    yesterday











  • Sorry, I updated my original answer - it's pretty ugly but works on regex101.

    – Nav
    yesterday












  • 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
    yesterday
















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
yesterday





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
yesterday













Sorry, I updated my original answer - it's pretty ugly but works on regex101.

– Nav
yesterday






Sorry, I updated my original answer - it's pretty ugly but works on regex101.

– Nav
yesterday














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
yesterday





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
yesterday

















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?