Create a newline from computed string - vuejs2

I would like to know how to add a newline in a computed string with the concatenation of string values. I need the values to be this.
1111 Ave, Apt 107
Iowa mycity, myzip
Here's what I have.
companyAddress()
{
return this.lead.address + ", " + this.lead.address2 + '\n' +
this.lead.state + ", " + this.lead.city + " " + this.lead.zip;
}
I get values no problem, but I can't get the \n to separate to two lines.

You can use v-html in your template.
<span v-html="companyAddress"></span>
companyAddress() {
return `${this.lead.address, ${this.lead.address2} <br> ${this.lead.state}, ${this.lead.city} ${this.lead.zip}`;
}

Related

In Kotlin, how to check if the input is alphabetic only

In kotlin, how to check if the input is alphabetic only.
Input could be anything, a String, Int or Double etc.
For example
val input = readLine()
if(check) {
doSomeTask
}
else doSomethingElse
You can have a look here, there are a lot of examples.
for example you can check via
fun isLetters(string: String): Boolean {
return string.all { it.isLetter() }
}
A good answer for checking if a String is entirely alphabetical was given by #HakobHakobyan: String.all { it.isLetter() }.
I will borrow his solution to target a second aspect of your question, that is
Input could be anything, a string, int or double etc.
Here's another method that checks Any input type:
fun isAplhabetical(input: Any): Boolean {
when (input) {
// if the input is a String, check all the Chars of it
is String -> return input.all { it.isLetter() }
// if input is a Char, just check that single Char
is Char -> return input.isLetter()
// otherwise, input doesn't contain any Char
else -> return false
}
}
and it can be used in an example main() like this:
fun main() {
val a = "Some non-numerical input"
val b = "45"
val c = "Some numbers, like 1, 2, 3, 4 and so on"
val d: Int = 42
val e: Double = 42.42
val f: Float = 43.4333f
val g = "This appears as entirely alphabetical" // but contains whitespaces
val h = "ThisIsEntirelyAlphabetical"
println("[$a] is" + (if (isAplhabetical(a)) "" else " not") + " (entirely) alphabetical")
println("[$b] is" + (if (isAplhabetical(b)) "" else " not") + " (entirely) alphabetical")
println("[$c] is" + (if (isAplhabetical(c)) "" else " not") + " (entirely) alphabetical")
println("[$d] is" + (if (isAplhabetical(d)) "" else " not") + " (entirely) alphabetical")
println("[$e] is" + (if (isAplhabetical(e)) "" else " not") + " (entirely) alphabetical")
println("[$f] is" + (if (isAplhabetical(f)) "" else " not") + " (entirely) alphabetical")
println("[$g] is" + (if (isAplhabetical(g)) "" else " not") + " (entirely) alphabetical")
println("[$h] is" + (if (isAplhabetical(h)) "" else " not") + " (entirely) alphabetical")
}
The output is
[Some non-numerical input] is not (entirely) alphabetical
[45] is not (entirely) alphabetical
[Some numbers, like 1, 2, 3, 4 and so on] is not (entirely) alphabetical
[42] is not (entirely) alphabetical
[42.42] is not (entirely) alphabetical
[43.4333] is not (entirely) alphabetical
[This appears as entirely alphabetical] is not (entirely) alphabetical
[ThisIsEntirelyAlphabetical] is (entirely) alphabetical
Only the last String is entirely alphabetical.
You can use a regex with the alphabet range:
fun alphabetCheck(input: String): Boolean {
val regex = Regex("[a-zA-Z]+?")
return regex.matches(input)
}
First convert your input to string by using toString():
val str = input.toString()
val matchesAlphabet = alphabetCheck(str)
You can check the ascii value of a character as in the example:
fun main(args: Array) {
val c = 'a'
val ascii = c.toInt()
println("The ASCII value of $c is: $ascii")
}
If you look at the ascii table, you can see that alphabetic characters are the one between the values 65 and 90 for capital letters. For small letters you have the interval 97 - 122.
If you want to build an arbitrary lookup (say characters that fit an encoding like base 64) you can do this kind of thing too:
val acceptable = ('a'..'z').plus('A'..'Z').plus("+-/~".asIterable())
So that's using ranges as a quick way of defining a... range of characters, and using a string to easily specify some individual ones (and turning it into an Iterable<Char> so plus can add them to the list.
val Char.isAcceptable get() = this in acceptable
"ab+5%".filter(Char::isAcceptable).let { print("VIPs: $it")}
>>>> VIPs: ab+

Need to validate an error message with multiple random strings using selenium Java

I have to validate an error message getting populated for 10 fields, 10 field names will be mentioned in the error message together.
Example :
Error message:10 fields got over lapped and 10 field names are ac, bc, dc..
Can you please help me to write the logic to validate the error message having all random strings.
Need to pass all strings values in to the creates string to compare the error message.
Map<String,String> m = arg1.asMap(String.class,String.class);
System.out.println("\nFilling form with below data\n");
for( String fieldname : m.keySet())
{
//Need to pass this field name to the error message and the error message may have multiple fieldnames//
System.out.println("Key -> " + fieldnames + " Value -> " + m.get(fieldnames));
}
}
You can get key and values as following and here is a good answer for how to use Map and EntrySet :
Map<String,String> map = arg1.asMap(String.class,String.class);
for (Entry<String, String> entry : map.entrySet()) {
System.out.println(entry.getKey() + "=" + entry.getValue());
}
OUTPUT :
key1=value1
key2=value2
.
.
.
As an answer of your question for how to assert them :
List<String> fieldNames = new ArrayList<String>();
Map<String,String> map = arg1.asMap(String.class,String.class);
int i = 0;
for (Entry<String, String> entry : map.entrySet()) {
System.out.println(entry.getKey() + "=" + entry.getValue());
fieldName.add(entry.getKey());
i++;
}
Assert.assertEquals(errorMessage, "Error message:" + i + "fields got over lapped and" + i + "field names are" + fieldName.toString() );

"background-image:url("+bg+")" , what is the + sign for ? Vue.js

"background-image:url("+bg+")" , what is the + sign for ? Vue.js
as title . i dont understand why there are + sign added in url() ?
computed:{
content_bg(){
return "background-image:url(" + this.poiInfo.head_pic_url + ")"
},
any answer will be appreciated!
The + sign is not for the url. It is being used as string concatenation operator here. It adds the second string at the end of the first string. For example "a" + "b" equals "ab".
Your function is returning an string. If the value of this.poiInfo.head_pic_url is, lets says, www.example.com/head_pic then your function content_bg() will return a string value of background-image:url(www.example.com/head_pic).
content_bg(){
return "background-image:url(" + this.poiInfo.head_pic_url + ")"
},

Operations on state of array

I am developing an application on ReactNative, which works over geoquery. Simply, I am getting data with the help of geoquery then showing in FlatList.
But the problem is that I am using an state of array as,
this.state = {
data: []
}
How to add the keys I am getting from geoquery in this state of array.
I am using geoquery as,
geoQuery.on('key_entered', (key, location, distance) => {
console.log(key + " entered query at " + location + " (" + distance + " km from center)");
})
I want to add key getting from geoquery to an state of array, then get data of related key from firebase with the help of state of array containing key.
As per my understanding from your question, you can do something like below:
geoQuery.on('key_entered', (key, location, distance) => {
console.log(key + " entered query at " + location + " (" + distance + " km from center)");
this.setState({data: [...this.sate.data, key]});
})

How to use variables in modal function's position option in SimpleModal 1.4.4

I am having an issue inserting variables into the modal functions position option. The following works:
$.modal('<iframe id = "framedetails" src="' + src + '" height="' + vHeight + 'px;" width="' + vWidth + 'px;" style="border:0"></iframe>', {
closeHTML:"<a href='#' class='modalCloseImg' alt='Close/Cancel' title='Close/Cancel'><a>", //add close button
fixed: false,
position: ["75px","595.5px"],
overlayClose:false
});
How would I insert a variable for each of the position values? I am unable to get the concatenation correct and have tried many variations.
For example, position: ["" + vTop + "","" + vLeft + ""] seems to insert the value for vTop but the vLeft variable is not being applied. If I supply the actual value in this for vLeft, it works as expected. What am I missing here?
I figured this out...pretty silly of me. I just create a string array of the two variables (vTop and vLeft) and passed them in.
vArray = ["" + vTop + "","" + vLeft + ""];
...
position: vArray