I have a Cordova config.xml file and I'm writing a script to bump up the version. A sample of the file is:
<?xml version="1.0" encoding="utf-8"?>
<widget android-packageName="com.demo.android" id="com.demo.ios" ios-CFBundleIdentifier="com.demo.ios.dev" version="1.16.6" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name short="DEMO DEV">DEMO</name>
I want to replace the value of the attribute version that is inside the <widget> tag, but without affecting at all any other attribute, including the one in the <?xml tag.
So, simply put, find and replace the value of the attribute version inside the widget tag.
(?<=\<widget.*(?<=version\=\"))(\d+\.?)+and then replace the string with suitable replacement.widgettag. If not, can it possibly not have a version ? Because the whole<widget.*?version=thing just won't cut it. That's why I posted a hairy regex, to avoid such trivia, and is the only way it can be done.