I designed a mobile web page. There I have a phone number field, which on clicking should call that particular number. I can't use:
![Phone Phone](https://community-cdn-digitalocean-com.global.ssl.fastly.net/assets/tutorials/images/large/python.png?1513019661)
Because I have added the phone number field using table tag as follows:
Is there any other methods(like OnClick event) to call that phone number on clicking that column?
user53770377,9741212 gold badges2929 silver badges6262 bronze badges
msgmsg63833 gold badges1111 silver badges2121 bronze badges
closed as off-topic by PeeHaa, Fraser, Dom, Amit, GravitonJul 29 '13 at 3:02
This question appears to be off-topic. The users who voted to close gave this specific reason:
- 'Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist' – PeeHaa, Fraser, Dom, Amit, Graviton
3 Answers
EhsanEhsan25.4k66 gold badges4747 silver badges5757 bronze badges
You can simply add an
onclick
handler to your <tr>
tag, then call window.open('tel:+1800229933');
.Like so:
idmadjidmadj1,07611 gold badge1111 silver badges1717 bronze badges
Find the cell content with jQuery, replace the 'Phone:' part and make it a link. The selection of the cell with a class is one way of doing it. Another would be to select in the real table the cell with a code similar to 'the second cell in each row of the table'.Here a working example:
user1525604user1525604
Not the answer you're looking for? Browse other questions tagged javascripthtml or ask your own question.
the following python script allows me to scrape email addresses from a given file using regular expressions.
How could I add to this so that I can also get phone numbers? Say, if it was either the 7 digit or 10 digit (with area code), and also account for parenthesis?
My current script can be found below:
Regex for phone numbers:
Another regex for phone numbers: Mount and blade faction specialties.
Aaron
AaronAaron99744 gold badges1616 silver badges3636 bronze badges
7 Answers
If you are interested in learning Regex, you could take a stab at writing it yourself. It's not quite as hard as it's made out to be. Sites like RegexPal allow you to enter some test data, then write and test a Regular Expression against that data. Using RegexPal, try adding some phone numbers in the various formats you expect to find them (with brackets, area codes, etc), grab a Regex cheatsheet and see how far you can get. If nothing else, it will help in reading other peoples Expressions.
Edit:Here is a modified version of your Regex, which should also match 7 and 10-digit phone numbers that lack any hyphens, spaces or dots. I added question marks after the character classes (the []s), which makes anything within them optional. I tested it in RegexPal, but as I'm still learning Regex, I'm not sure that it's perfect. Give it a try.
It matched the following values in RegexPal:
AugusteAuguste
This is the process of building a phone number scraping regex.
First, we need to match an area code (3 digits), a trunk (3 digits), and an extension (4 digits):
Now, we want to capture the matched phone number, so we add parenthesis around the parts that we're interested in capturing (all of it):
The area code, trunk, and extension might be separated by up to 3 characters that are not digits (such as the case when spaces are used along with the hyphen/dot delimiter):
Now, the phone number might actually start with a
(
character (if the area code is enclosed in parentheses):Now that whole phone number is likely embedded in a bunch of other text:
Now, that other text might include newlines:
Enjoy!
I personally stop here, but if you really want to be sure that only spaces, hyphens, and dots are used as delimiters then you could try the following (untested):
dotancohendotancohen15.5k2222 gold badges106106 silver badges158158 bronze badges
I think this regex is very simple for parsing phone numbers
Andy♦32.6k2121 gold badges114114 silver badges171171 bronze badges
user4959user4959
For spanish phone numbers I use this with quite success:
Alex MoleiroAlex Moleiro
Dive Into Python has a specific example of what you're looking for here:
attomos69433 gold badges1313 silver badges2626 bronze badges
Dan McDougallDan McDougall5,16322 gold badges1212 silver badges1616 bronze badges
You can check : http://regex.inginf.units.it/. With some training data and target, it constructs you an appropriate regex. It is not always perfect (check F-score). Let's try it with 15 examples :
PC / Computer - Sonic Generations - The #1 source for video game models on. Sonic the Hedgehog (Classic). My 3D modeling software can't open DAE's. Free Sonic The Hedgehog 3D models for download, files in 3ds, max, c4d, maya, blend, obj, fbx with low poly, animated, rigged, game, and VR options. 3d model of sonic. Free Sonic 3D models in OBJ, Blend, STL, FBX, Three.JS formats for use in Unity 3D, Blender, Sketchup, Cinema 4D, Unreal, 3DS Max and Maya. Jun 16, 2017 - Original model exported from Sonic Generations (Recommended for rendered animation) + HD textures and an already configured and textured blend file. It's not append able or a.obj file. And can it be made into a rigged obj file? Sonic The Hedgehog 3D models for download, files in 3ds, max, c4d, maya, blend, obj, fbx with low poly, animated, rigged, game, and VR options.
Call Python Script With Argument
returns
J. DoeJ. Doe['04 42 00 00 00', '04.42.00.00.00', '04-42-00-00-00', '50498,']
add more examples to gain precision1,42722 gold badges77 silver badges2424 bronze badges
Since nobody has posted this regex yet, I will. This is what I use to find phone numbers. It matches all regular phone number formats you see in the United States. I did not need this regex to match international numbers so I didn't make adjustments to regex for that purpose.
Use this pattern if you want simple phone numbers with no characters in between to match. An example of this would be: '4441234567'.
Th3Tr1ckst3rTh3Tr1ckst3r
Not the answer you're looking for? Browse other questions tagged pythonregex or ask your own question.
I'd like to call a Python function from JavaScript code, because there isn't an alternative in JavaScript for doing what I want. Is this possible? Could you adjust the below snippet to work?
JavaScript code:
~/pythoncode.py
contains functions using advanced libraries that don't have an easy to write equivalent in JavaScript:3,89466 gold badges2929 silver badges6060 bronze badges
xralfxralf7,2312929 gold badges9595 silver badges148148 bronze badges
4 Answers
All you need is to make an ajax request to your pythoncode.You can do this with jquery http://api.jquery.com/jQuery.ajax/, or use just javascript
Salvador DaliSalvador Dali124k9090 gold badges531531 silver badges626626 bronze badges
From the
document.getElementsByTagName
I guess you are running the javascript in a browser.The traditional way to expose functionality to javascript running in the browser is calling a remote URL using AJAX. The X in AJAX is for XML, but nowadays everybody uses JSON instead of XML.
For example, using jQuery you can do something like:
You will need to implement a python webservice on the server side. For simple webservices I like to use Flask.
A typical implementation looks like:
You can run IronPython (kind of Python.Net) in the browser with silverlight, but I don't know if NLTK is available for IronPython.
Call Python Script From Excel
Paulo ScardinePaulo Scardine42.3k88 gold badges9494 silver badges118118 bronze badges
Typically you would accomplish this using an ajax request that looks like
Asad SaeeduddinAsad Saeeduddin38.3k55 gold badges6565 silver badges110110 bronze badges
You cannot run .py files from JavaScript without the Python program like you cannot open .txt files without a text editor. But the whole thing becomes a breath with a help of a Web API Server (IIS in the example below).
- Install python and create a sample file test.py
- Create a method in your Web API Server
- And now for your JavaScript:
Remember that your .py file won't run on your user's computer, but instead on the server.
Community♦
Python Script To Call Phone Free
azakgaimazakgaim