using Regex in gedit for search and replace - gedit

I want to replace all occurring characters after comma with );
in a text like this:
mapMessage.getString("obj_file_path", user_ftp_path + app_path);
mapMessage.getString("storeid", storeid+"");
mapMessage.getString("name_farsi", name_farsi);
mapMessage.getString("name_english", name_english);
mapMessage.getString("group", group+"");
mapMessage.getString("price", app_price+"");
mapMessage.getString("icon", icon);
mapMessage.getString("app_path", app_path);
mapMessage.getString("desc_farsi", desc_farsi);
mapMessage.getString("desc_english", desc_english);
mapMessage.getString("isfarsi", isfarsi);
mapMessage.getString("tags", tags);
mapMessage.getString("shot1", shot1);
mapMessage.getString("shot2", shot2);
mapMessage.getString("shot3", shot3);
mapMessage.getString("shot4", shot4);
mapMessage.getString("shot5", shot5);
mapMessage.getString("changes_fa", changes_fa);
mapMessage.getString("changes_en", changes_en);
mapMessage.getString("upload_real_address", upload_real_address);
mapMessage.getString("apk_upload", apk_upload);
mapMessage.getString("app_upload_valid_shot", app_upload_valid_shot);
so after the replace was done for example the first line should looks like:
mapMessage.getString("obj_file_path");

I think all you need is to do a search-and-replace for ,.*$ with );
Make sure the "Regular expression" checkbox is selected.

Related

How can I read values from a configuration file (text)?

I need to read values (text) from a configuration file named .env and assign them to variables so I can use them later in my program.
The .env file contains name/value pairs and looks something like this:
ENVIRONMENT_VARIABLE_ONE = AC9157847d72b1aa5370fdef36786863d9
ENVIRONMENT_VARIABLE_TWO = 73cad721b8cad6718d469acc42ffdb1f
ENVIRONMENT_VARIABLE_THREE = +13335557777
What I have tried so far
read-values.red
Red [
]
contents: read/lines %.env
env-one: first contents
env-two: second contents
env-three: third contents
print env-one ; ENVIRONMENT_VARIABLE_ONE = AC9157847d72b1aa5370fdef36786863d9
print env-two ; ENVIRONMENT_VARIABLE_ONE = 73cad721b8cad6718d469acc42ffdb1f
print env-three ; ENVIRONMENT_VARIABLE_ONE = +13335557777
What I'm looking for
print env-one ; AC9157847d72b1aa5370fdef36786863d9
print env-two ; 73cad721b8cad6718d469acc42ffdb1f
print env-three ; +13335557777
How do I continue or change my code and parse these strings such as the env- variables will contain just the values?
env-one: skip find first contents " = " 3
See help for find and skip
Another solution using parse could be:
foreach [word value] parse read %.env [collect some [keep to "=" skip keep to newline skip]] [set load word trim value]
This one will add the words to the global context ENVIRONMENT_VARIABLE_ONE will be AC9157847d72b1aa5370fdef36786863d9 and so on.

VB.Net Convert text to WWW form

I want to convert text into the WWW form.
E.g: # should be %40, % should be %25 etc...
There's fine encoder here, but i want to do it in VB.Net.
I need this for httpwebrequest, i think it has something to do with x-www-form-urlencoded.
You can use the Uri.EscapeDataString() method for that:
Dim OriginalURL As String = "http://www.example.com/some file with spaces.php?q1=plus+&q2=at#&q3=svenska språkets 'ö'"
Dim EncodedURL As String = Uri.EscapeDataString(OriginalURL)
Online test: https://ideone.com/h5fqm1
And if you want to just escape parts of the URL but still keep valid components such as : / = ? & (etc.) you'd use Uri.EscapeUriString().

How to write value to input field

I am getting element with
var nameEl = document.getElementById("<portlet:namespace />kategorijaName");
that is input field.How can i write some text in it ?
Since the question (at this time) is tagged liferay and alloy-ui, I am assuming an answer using/appropriate for those two tags would be beneficial
<aui:input id='textFieldId' name='textFieldName' label='My Text Field'></aui:input>
<script>
AUI().use('node', function(A){
A.one('#<portlet:namespace/>textFieldId').set('value', "A new input value");
});
</script>
if you are using normal javascript then you can use below for setting a value in input text
document.getElementById("<portlet:namespace />kategorijaName").value = 'some value';
in case of Jquery you can use
$("#<portlet:namespace />kategorijaName").val("some value");
If you are using alloy-ui then you can set value like this
<aui:script>
A.one('#<portlet:namespace />kategorijaName').set('value',kategorijaName);
</aui:script>
nameEl.value = "value you need"

Url parameters values with special characters are providing errors in view

I have edited Url manager to provide SEO friendly urls but getting problem when the url have values with special characters such as . or () or - or any other special character
http://localhost/nbnd/search/city/delhi
In city action
var_dump($_GET);
output: array(1) { ["city"]=> string(6) "delhi" }
but when url is with some special character
http://localhost/nbnd/search/city/north-delhi or
http://localhost/nbnd/search/city/north.delhi or
http://localhost/nbnd/search/city/(north)delhi
In city action
var_dump($_GET);
Output : array(1) { ["north-delhi"]=> string(0) "" }
and so for other
this change in array values results in error.
As you want all sorts of characters, change your rule from the related question/answer:
'<controller:\w+>/<action:\w+>/<city>'=>'<controller>/<action>',
// omit the pattern \w+ from city:\w+
Documentation:
In case when ParamPattern is omitted, it means the parameter should match any characters except the slash /.

How can I automatically minify my webpages?

All of my .html and .php webpages should be minified. That means I would like to get all HTML-comments and more than one whitespace-character stripped.
Does an Apache-module exist for minification?
(Or perhaps another method to automatically add a script directly before the output gets sent to the user?)
(I could add a function like the following, but if an Apache-module or another automatic solution existed, I could not forget to do so.)
<?
function sanitize_output($buffer)
{
$search = array(
'/\>[^\S ]+/s', //strip whitespaces after tags, except space
'/[^\S ]+\</s', //strip whitespaces before tags, except space
'/(\s)+/s' // shorten multiple whitespace sequences
);
$replace = array(
'>',
'<',
'\\1'
);
$buffer = preg_replace($search, $replace, $buffer);
return $buffer;
}
?>
Try mod_pagespeed which may be of some use to you.