URL rewrite with multiple parameters - .htaccess

I need to convert an URL, with some params like this (where the letters l,v and n represents input parameters).
/anytext/l1v5n3
to a an URL containing a query string:
/index.php?liv=1&id=5&lang=3
The parameters l, v, n could be in any order and the following value could be numeric and can include special symbols (+,-, etc.)
Any help will be appreciated!

Related

How can I consider special character(&) as value in one of the query parameter

In GET API I have value as,
title=my&title
where the value from query param title returns only my and splits from & character.
Can anyone help me with how can I include & in my value?
Your query parameters should be URL-encoded in order to differenciate a separating & from a random character.
The solution is to encode the value before sending it through the request. You can do so by passing your value to encodeURIComponent(). You can then parse it the same way and decode it using decodeURIComponent(), e. g. :
encodeURIComponent('my&title') -> 'my%26title'
decodeURIComponent('my%26title') -> 'my&title'

Is there a way to know what is the url before it will be encoded?

I want to know if there is a way to know the inputted URL before encoding.
My problem is once I enter the URL, space automatically encodes to %20. For example, I have a URL that has this parameter ?a=on e
I need to get this string "a=on e" because I need to differentiate whether the user input is a space or %20.
on%20e is data you got from uri encode. So if you want to get correct data from url, you mus decode query param.
For ex:
String encodeResult = URLEncoder.encode(q, "UTF-8"); System.out.println(encodeResult); // result is on%20e
String decodeResult = URLDecoder.decode(encodeResult); System.out.println(decodeResult); // result is on e
You only need to keep in mind to encode only the individual query string parameter name and/or value, not the entire URL

Pentaho convert string to integer with decimal point

I am importing text values into a transformation using a Fixed Width input step. Everything is coming in as a string. I want to convert some of the string values to integers with a decimal point at a specified spot. Here are some examples of the before (left hand side) and expected results (right hand side):
00289 --> 0028.9
01109 --> 0110.9
003201 --> 0032.01
I've tried numerous combinations of the Format mask in a Select Values step (meta data tab) but I can't get the values I'm looking for.
Can you anyone tell me what combination I can try for* Type/Length/Precision/Format/Encoding/Decimal/Group* attributes for these fields to get the desired output?
Have you tried another step the reach your goal? You can try to use e.g. User Defined Java Expression setting it in this way:
Java expression: new java.math.BigDecimal(text.substring(0,4) + "." + text.substring(4,text.length()))
Value type: BigNumber
But this will convert your input to:
00289 --> 28.9
01109 --> 110.9
003201 --> 32.01
Because its output is BigNumber format. BigNumber or Number format can be used for decimal numbers. You cannot use Integer for decimals because it has no decimal part.
If you want a String output leave out the new java.math.BigDecimal() part from the expression above and set Value type to String. It will produce these results:
00289 --> 0028.9
01109 --> 0110.9
003201 --> 0032.01
This is the one suggestion. Of course there are another ways of how to reach your goal.

Matlab: Remove fields with similar string names in a single command

So I have a structure, r, that contains multiple headers of the form:
Header_0001
Header_0002
Header_0003, and so on whose names are represented as strings.
Is there a way to format the strings so that I can remove these headers with a single command?
i.e.
r=rmfield(r,Header_00XX)
where X can be any number. I have tried using wildcards, anchors, etc. but have not found a method that works as of yet.
Try this:
fields = fieldnames(r);
r = rmfield(r, fields(find(~cellfun(#isempty,strfind(fields, 'Header_00')))))

Find a pattern in given string of URLs in Lua

In my Lua code I am receiving lot of URLs in form of string.
Example :
['http://www.abc.com/home/', 'http://www.abc.com/', https://www.xyz.com/v/123443/css/' , http://www.xyz.com/css/' ]
I want to fetch those URLs which are like :
https://www.xyz.com/v/123443/css/ where v is pre-defined string pattern and 123443 is random version generated to URL.
Please help me to fetch all URLs which are having that pattern into it like :
"/v/12332323/"
str = "https://www.xyz.com/v/123443/css/"
print(str:match("https?://www%.[^/]+(/v/%d+/)%w+"))
Output: /v/123443/
This pattern matches strings that starts with http or https, and then ://, the website name starting with www., a /, the pre-defined string v and "random" numbers, followed by / and other stuff.

Resources