how can i extract rapidminer xpath value from javascript - rapidminer

I would like to extract rapidminer xpath value for longitude and latitude embedded in javascript.
< script type = "text/javascript" >
$("document").ready(function() {
MultiMaps.init('{"elementName":"map","latitude":"55.046253842870506","longitude":"-8.275406306447621","zoom":16,"showMarker":true,"showArea":false,"areaSize":0,"showControls":1,"draggable":1,"maxZoom":18,"minZoom":7,"hitcode":"100","zoomLocked":false,"lateLoad":true,"lateLoadIds":"#smi-map-link","bizmapWaitTime":"800","multipleAreas":[],"mapButtons":["map-button"],"satButtons":["sat-button"],"svButtons":["sv-button"],"clustering":true,"isMarkerDraggable":false,"jumpToGoogleIds":"","key":"AIzaSyBvf2e2eg1SyR7Lq5INzGDrIInkgKHT1oI","onlyGoogle":true,"lazyLoad":false}');
}); < /script>
I tried
//h:html/head/script[#type='text/javascript']//text()
to at least extract all the text from the javascript but it is not working for me. Any suggestions?

You will need to use JAVA string functions. Find the starting point of the latitude and then extract n number of characters. Do the same for longitude.

Related

Parse JSON for data after keyword

I have some JSON data in Google Sheets that I wish to parse for the data after a keyword, eg:
"splashtopname":"DESKTOP-XXYYZZ"
This is in the middle of the JSON data which is delimited by commas eg:
"cpuidentifier":"Intel64 Family 6 Model 92 Stepping 9","splashtopname":"DESKTOP-XXYYZZ","splashtopversion":"3.4.6.2",
What I want to do is extract DESKTOP-XXYYZZ only from this (however this string length is variable and not fixed, nor does it always begin DESKTOP). I am stumped as to the formula to get this output, so any help would be greatly appreciated.
Thanks in advance!
Using REGEXEXTRACT should achieve your wanted data.
Formula:
=REGEXEXTRACT(A1, """splashtopname"":""([^""]*)""")
Simply extract <capture> from pattern "splashtopname":"<capture>" via regex.
Output:

Packing an emoji as plain text unicode string php

I have a website and Unity project that communicate with one another through a web server using web sockets. I am encoding/decoding the messages I am sending using json. On the Unity side, I am using Newtonsoft for json and websocketsharp for WebSockets. Messages send fine and everything is working, but now I am trying to implement emojis in Unity to display correctly. I was able to create a sprite sheet of all emojis, create a dictionary with the key's being their Unicode and values being their position in the sprite sheet. The issue is that when I receive an emoji (for example the 🤐emoji Unicode: U+1F910), Unity receives it as "\uD83E\uDD10". Is there a way to send the emoji as a string literal of its Unicode? If not is there a way to parse the c# interpreted Unicode back to the original Unicode? I have found regex which converts more common symbols from the above format back to the corresponding symbol but does not give me back the Unicode as a string. Here is what I am currently using to do that:
var result = Regex.Replace(
arrivedMessages[0],
#"\\[Uu]([0-9A-Fa-f]{4})",
m => char.ToString(
(char)ushort.Parse(m.Groups[1].Value, NumberStyles.AllowHexSpecifier)));
With the above code, if the user were to send a symbol such as º, the decoded json will read \u00ba, but the above regex will convert it back to º. When I try to send an emoji, such as the 🤐symbol, the json will read "\ud83e\udd10" and the regex result will be blank. Is there an issue with the regex? Or is there a better way to go about doing this? Thanks!
Edit:
To simplify the overall question: Is there a way to convert "\uD83E\uDD10" back to a string literal of the Unicode "U+1F910"
Here is the function I ended up using to convert the surrogate pairs as #Mr Lister pointed out:
string returnValue = "";
for (var i = 0; i < SurrogatePairString.Length; i += char.IsSurrogatePair(SurrogatePairString, i) ? 2 : 1)
{
var codepoint = char.ConvertToUtf32(SurrogatePairString, i);
// keep it uppercase for the regex, then when it is found, .ToLower()
returnValue = String.Format("U+{0:X4}", codepoint);
}

Is it possible to pass a datatype with a particular property in csv2geojson.js?

I am using https://github.com/mapbox/csv2geojson API to convert CSV file to GeoJSON and then trying to use data-driven coloring to interpolate a property.
csv2geojson.js converts all the other values to strings by default. Is there a way to pass a particular datatype for a property?
Looking at the source code, there's no support for other data types. But you could add it fairly easily by changing this line:
var parsed = (typeof x == 'string') ?
dsv.dsvFormat(options.delimiter).parse(x) : x;
You need to parse a row conversion function to .parse().

google app scripts Utilities.FormatDate malfunction

In need to obtain a date in a integer format ddmmyyyy using as argument a cell that contains a date in standard google spreadsheet format.
That's the code.
function getDateToInt(date) {
ddmmyyyy = Utilities.formatDate(date,SpreadsheetApp.getActive().getSpreadsheetLocale(),'dd/MM/yyyy');
var array = new Array();
array = (ddmmyyyy.split('/'));
return (parseInt(array[2])*100+parseInt(array[1]))*100+parseInt(array[0]);
}
Here the problem:
The function behave as expected in all case except when the month in the argument date is 8 or 9. In these cases returns #NUM!.
Any contribution is welcome.
If you are interested in using just a formula, the formula
=value(A1)
where a1 is a standard date such as 1/1/2016 with return "42370"
the number integer of the date.
parseInt() uses 2 arguments, the variable to parse and the base.
The base is frequently omitted and assumed to be 10 but this is actually not ideal. Read the doc here.
I guess that adding the base parameter will solve the issue you have but you can alternatively use the Number() function which will also convert the string into a number.

XSLT 2.0 replace function returns same string when comparing special html characters

I am writing an XSLT to produce HTML for HTML Help Viewer 1.0. Some of the titles contain the < and > sequences. This causes loads of problems with the viewer as it converts them back to angle brackets. Having read on-line that having them as there Unicode versions will work (http://mshcmigrate.helpmvp.com/faq/notes10) I tried to use the replace function to do this and the result is the same as the input.
The code I am using is:
replace(replace(/*/name, '<', '<'), '>', '>')
The input:
DocumentationTest.GenericClass<T> Namespace
Outputs as:
DocumentationTest.GenericClass<T> Namespace
How can I perform a string replace to get this output?
DocumentationTest.GenericClass<T> Namespace
< and < are two different representations of the same character. You can use replace() (or more simply, translate()) to change one character to another, but you can't use it to control how that character is represented in the serialized output - that's entirely up to the serializer. You can influence it, however, using character maps - see xsl:character-map.
This is correct behavior as per the XML parser itself, which executes before XSLT gets ahold of it. If you must maintain the < in the document, then it should be encoded as &lt;, and a simple find and replace on all & symbols, replacing them with &, should do the trick.