SwiftUI how to change font and color for email address in Text - text

If I didn't use verbatim with Text
Ex:
Text("Reach out to us on info#eyva.io for any queries!")
.foregroundColor(Color.white)
.font(Font.custom("Poppins-Regular", size: getFontSize(value: 16)))
Output:
And, if I used verbatim with
Text(verbatim: "Reach out to us on info#eyva.io for any queries!")
Ex:
Text(verbatim: "Reach out to us on info#eyva.io for any queries!")
.foregroundColor(Color.white)
.font(Font.custom("Poppins-Regular", size: getFontSize(value: 16)))
Output:
Email clickable functionality not working if I used verbatim with Text()
I want to with email clickable.

Try the below code It will help you:
Text(.init("Reach out to us on [cinfo#eyva.io](cinfo#eyva.io) for any queries!"))
.accentColor(.red)
here in the () round bracket, you have to write the link and in [] square bracket the respective text you want to see, here you want to show the email so in both brackets I wrote the email id modify as you want.

Related

How would I isolate a string between two strings in DiscordJS?

I've currently been using this script:
var portion = body.substring(
str.lastIndexOf('ID Background',") + 1,
str.lastIndexOf('ID Theme',")
);
"Body" is the input, "Portion" being the output.
I'm trying to isolate text between the words strings "ID Background" and "ID Theme"
Example:
ID Background
Background information Background information Background information Background information
ID Theme
Theme information Theme information Theme information Theme information Theme information
...Et Cetera.
Expected Output:
Background information Background information Background information
Current Output:
undefined
I cannot figure out why this script is not working. I'm using this for a Discord bot (Discord.JS)
You should use RegExp capturing groups ()
// objective: get everything in between 'start' and 'end'
const str = 'start hello how was your day end';
// capture everything in between the two words in parentheses
console.log(str.match(/start (.*) end/)[1]);
Since you're example uses line breaks, which the special character . doesn't cover, you should use [\s\S] (\s is whitespace, and \S is anything but whitespace. Together, they cover everything. Also, use optional chaining ? so that your code doesn't throw a TypeError if no match is found.
var portion = body.match(/ID Background *([\s\S]*) *ID Theme/)?.[1];
if (!portion)
// no match found...

Netsuite Custom Field with REGEXP_REPLACE to strip HTML code except carriage return

I have a custom field with some HTML code in it:
<h1>A H1 Heading</h1>
<h2>A H2 Heading</h2>
<b>Rich Text</b><br>
fsdfafsdaf df fsda f asdfa f asdfsa fa sfd<br>
<ol><li>numbered list</li><li>fgdsfsd f sa</li></ol>Another List<br>
<ul><li>bulleted</li></ul>
I also have another non-stored field where I want to display the plain text version of the above using REGEXP_REPLACE, while preserving the carriage returns/line breaks, maybe even converting <br> and <br/> to \r\n
However the patterns etc... seem to be different in NetSuite fields compared to using ?replace(...) in freemarker... and I'm terrible with remembering regexp patterns :)
Assuming the html text is stored in custitem_htmltext what expression could i use as the default value of the NetSuite Text Area custom field to display the html code above as:
A H1 Heading
A H2 Heading
Rich Text
fsdfafsdaf df fsda f asdfa f asdfsa fa sfd
etc...
I understand the bulleted or numbered lists will look crap.
My current non-working formula is:
REGEXP_REPLACE({custitem_htmltext},'<[^<>]*>','')
I've also tried:
REGEXP_REPLACE({custitem_htmltext},'<[^>]+>','') - didn't work
When you use a Text Area type of custom field and input HTML, NetSuite seems to change the control characters ('<' and '>') to HTML entities ('<' and '>'). You can see this if you input the HTML and then change the field type to Long Text.
If you change both fields to Long Text, and re-input the data and formula, the REGEXP_REPLACE() should work as expected.
From what I have learned recently, Netsuite encodes data by default to URL format, so from < to < and > to >.
Try using triple handlebars e.g. {{{custitem_htmltext}}}
https://docs.celigo.com/hc/en-us/articles/360038856752-Handlebars-syntax
This should stop the default behaviour and allow you to use in a formula/saved search.

How to scrape email address out of a string?

How do I get the email address from this html snippet?
As there are thousand of leads like this in a certain webpage and the text within it is not always found as it is seen here.
The only common thing is the email address located in the first position.
How can I get the email address and ignore the rest?
These are the elements:
<div class="gm_popup"><div class="gm_name">Adel Outfitters</div><div class="gm_address">1221 W 4th St</div><div class="gm_location">Adel, Georgia 31620<div style="display:none" class="w3-address-country">United States</div></div><div class="gm_phone"><span class="gm_phone_label">P:</span> 229-896-7105</div><div class="gm_email">adeloutfitters#yahoo.com<div><div class="gm_website">https://www.facebook.com/pages/Adel-Outfitters/132735763434461</div><br><a target="_blank" class="directions-link" href="http://maps.google.com/?saddr=+&daddr=1221+W 4th St, Adel, Georgia, 31620">Directions<span class="w3-arrow">different stuffs</span></a></div></div></div>
What I tried:
Set post = html.getElementsByClassName("gm_email")(0)
MsgBox post.innerText
The result:
adeloutfitters#yahoo.com
https://www.facebook.com/pages/Adel-Outfitters/132735763434461
Directionsdifferent stuffs
Expected output:
adeloutfitters#yahoo.com
The closing </div> tag is further down which is why you are getting the extra text. Can you chop off anything after a new line? Or check each word in the string and save the one with "#" in it? Bad way of going about it, but it would probably work...

In Watir, how to get the full text, from a portion of text?

I have a portion of HTML that looks similar to:
<table><tbody><tr>
<td><div> Text Goes Here </div></td>
<td> ... rest of table
There are no IDs, no Titles, no descriptors of any kind to easily identify the div that contains the text.
When an error occurs on the page, the error is inserted into the location where "Text Goes Here" is at (no text is present unless an error occurs). Each error contains the word "valid".
Examples: "The form must contain a valid name" or "Invalid date range selected"
I currently have the Watir code looking like this:
if browser.frame(:index => 0).text.includes? "valid"
msg = # need to get full text of message
return msg
else
return true
end
Is there any way to get the full text in a situation like this?
Basically: return the full text of the element that contains the text "valid" ?
Using: Watir 2.0.4 , Webdriver 0.4.1
Given the structure you provided, since divs are so often used I would be inclined to look for the table cell using a regular expression as Dave shows in his answer. Unless you have a lot of nested tables, it is more likely to return just the text you want.
Also if 'valid' may appear elsewhere then you might want to provide a slightly larger sample of the text to look for
. browser(:cell => /valid/).text
Try this
return browser.div(:text => /valid/).text
or
return browser.table.div(:text => /valid/).text
if the valid is not found, it should return nil.

jquery Auto-complete loads ASCII HTML Character Codes in to the Text Area

I am using jQuery AutoComplete plugin.
I have the data which has special characters as '/-&
When user clicks the text area, the autocomplete drop down shows the data correctly
for example:
don't drink
When user selects the text (don't drink)
In my textarea it load the value as ASCII characters:
don't drink
How can I have the data to load as normal data.
This is my autocomplete code:
var directions ="don't drink/ Once a Day/ Take More/ You'are Good";
directions = directions.split("/");
$("#TextArea").autocomplete(directions, {
matchContains: true,
minChars: 1
});
You can add formatResult to your autocomplete options specifying a function that decodes the result that's output to the text box.

Resources