objective c - help creating regular expression for format (#,#) - ios

A user enters his/her number of credit hours per course in my UITextField in this format....
4,3,4,3,3
(4 credit hours for 1st course, 3 credit hours for 2nd course, so on)
Conditions:
The user can only enter in MIN of 1 course and MAX 5 courses, the credit hours must be separated by a comma except for the last one, the string should contain only numbers and commas (no letters etc.) in that order.
I am trying to display an error message if conditions are violated. I think I will need to create a regExp. I am not sure how to create one since the user can enter in 2 courses so... (3,4) and still be okay. (like it cant follow a strict format like phone number).

Rather than letting the user enter what they think is correct and then telling them they're wrong at the end, consider implementing the text field delegate method textField:shouldChangeCharactersInRange:replacementString:. This doesn't preclude you using the regex, but you can also filter the characters typed by the user to prevent any letters and inform the user immediately when they make a mistake.

Related

Google sheets, block data entry if…

I have a simple google sheet, with Date, Client ID, Name, etc.
What I would like to do is block any kind of data entry IF the first letter of the Name is NOT UPPERCASE.
I know this might sound a bit silly, but the person entering data just won’t do as I ask, and enters Name's inconsistently. So I want it to be blocked and force him to go back, correct the first letter uppercase, and the be able to enter data.
Another option could be a pop up message that warns that the name has been entered incorrectly? Anything like that.
Thanks.
Create data validation rule for column with formula:
=EXACT(LEFT(A:A,1),UPPER(LEFT(A:A,1)))
change A:A to column reference with names

exclude certain text from keyword analysis in google sheets

I'm trying to do a little bit of analysis on the topics of emails I receive. I have the emails in a Google-sheet in the format below. I'm trying to count how often 'privacy' or 'confidentiality' are mentioned. My challenge is that pretty much every email signature mentions one of those words, so when i use SEARCH every cell returns TRUE.
Most email signatures start with similar phrases, so I tried deleting anything after those phrases with this formula:
=ArrayFormula(TRIM(LEFT(B1:B,MIN(IFERROR(FIND({" This email and any","IMPORTANT NOTICE", " Important notice","The information in this email"," The contents of this message"," Information in this email including"," This electronic mail message"," this message and any attachments"," This message is intended for the addressee only"," This email is CONFIDENTIAL"},B1:B),LEN(L2))))))
Column B is the column with the email body text in.
However that seems to be deleting text that follows words that aren't in my search (deleting everything after 'not' instead of 'IMPORTANT NOTICE' for instance).
Could anyone advise on either:
what's wrong with my above search
an alternate way of searching for 'privacy' and 'confidentiality' without including text from email signatures.
Example table:
|email title|email body|
|-----------|----------|
|Do you want to buy my stuff| Hi there, I'd like to know if you'd like to buy this thing I want to sell you. IMPORTANT: this email is private|
|two-for-the-price-of-one| I've a great offer for you! This email and attachments are private & confidential|
|Last chance to buy stuff!| Can we have a private call about whether you want to buy my stuff yet?|
In the example above I want to count row 3, but not rows 1 & 2, as the 'private' and 'confidential' mentions in 1 & 2 are in the signature.
Thanks!
I think I understand the error that you've described is occuring with your formula. Once the formula finds one of the values you are using to try to identify an email signature, such as " Important notice", and returns the location of that text, let's say position 96, it then uses 96 for all of the cells, like this: LEFT(B1:B,96). So you might not be able to do the compound arrayformula of an arrayformula that you are trying.
Using the formula like this, in B2, and dragging it down, should work though:
=ArrayFormula(TRIM(LEFT(B2,MIN(IFERROR(
FIND({" This email and any","IMPORTANT NOTICE", " Important notice","The information in this email"," The contents of this message"," Information in this email including"," This electronic mail message"," this message and any attachments"," This message is intended for the addressee only"," This email is CONFIDENTIAL"},B2),
LEN(L2))))))
Note: I'm not sure what value is in your L2.
But for the overall approach, it really depends on how well your terms to identify email signatures work, so as to exclude them from your final full text searches.

How to create new course on Openedx?

I have a new instance of openedx with no course.
I logged into it, but I cannot create course. Seems I can only consult them.
What to do to create a course on a new openedx instance ?
To create a course, follow these steps.
Sign in to your Open edX instance Studio.
Select New Course.
Enter the following information about your course.
Important
The values that you enter for the organization, course number, and course run cannot be edited after you create your course.
For Course Name, enter the title of your course. For example, the name might be “Sets, Maps, and Symmetry Groups”. Use title capitalization for the course title, and normal spacing and punctuation.
For Organization, you enter the identifier for your organization. Do not include spaces or special characters.
For Course Number, you enter both a subject abbreviation and a number. For example, for public health course number 207, enter PH207. For math course 101x, enter Math101x. Do not include spaces or special characters in the course number.
Note
If your course will be public, be sure to include the “x”. If it is exclusively an on campus offering, do not include the “x”.
For Course Run, you enter the term in which your course will run. For example, enter 2014SOND or T2_2014. Do not include spaces or special characters.
The value that you enter for the run does not affect the course start date that you define for the course. For more information, see Setting Start and End Dates.
The organization, course number, and course run values that you enter are used to create the URL for your course. Because URLs do not have an unlimited length, the total number of characters that you enter for these values must be 65 or fewer.
Select Create.
The Course Outline page opens. You can start developing course content. For more information, see Getting Started with Course Content Development.
More http://edx.readthedocs.io/projects/open-edx-ca/en/latest/set_up_course/creating_new_course.html#create-a-course
5.1. Creating a Course is your anwser.

Generating values for dropdown ONLY for 'C' of CRUD

When choosing 'Add' in CRUD, how best to generate a list of choices to pick from a dropdown?
For U/update - just display what's there...
The field contents starts with a letter, followed by five numeric digits:{A-I,K-N,Z}#####
Each letter has a different 'max' value for the numeric part.
So when adding a new record, I'd like to offer a listbox with one of each letter and that letter's highest numeric value + 10.
So, if the max 'A' as A00120, and max 'B' B00030 (etc) the listbox would have A00130 and B00040.. etc
Save the user having to figure out which is 'next' when generating a new record.
? Thanks,
Mark
This time I'll not be able to come up with ready to use solution, but I must say - everything is possible with ATK4. You just have to customize and extend it to fit your needs :)
Speaking about your question above - I guess you have to split it in multiple parts.
First part is about how to show select box on Create and readonly or disabled field on Update. I guess you can make some custom Form field or pin some action to existing Form Field hook. Not sure exactly what's better in this case.
Second one is about data structure. I believe that this field actually should be 2 fields in DB and maybe (only maybe) merged together in ATK model with addExpression() just for user interface needs to display these 2 fields as one field easily in UI. Maybe such concatenated field will be useful also for searching, but definitely not as only one field stored in DB. Imagine how hard it'll be for DB engine to find max value if such field. Store it like type = letter, num = number and then search like SELECT max(num)+10 FROM t WHERE type='A'
Finally Third part is about how to generate this next number. I read your question 3 times and came to conclusion that actually you don't have to show this +10 numeric value in UI at all if it's hardly predefined anyway. Actually that'll not work correctly if this will be multi-user system which I guess it will. Instead just show simple select box with letters {A-I,K-N,Z} and calculate this next value exactly before inserting data in DB. That can be done using models insert hook. This will be much more appropriate solution and will be better for UI and also more stable because calculated in model not incorrectly in UI part.

Rails Telephone field like a date field?

I using devise to allow users to register on my website. I have field for them to put in their telephone number when registering.
I however want to split the telephone field into 3 parts so you put in different parts of the number, kind of like a date.
Is it possible in rails to do something similar like you would with a date? When you have a date select on a form it gives the field names:
model[date(1i)]
model[date(2i)]
model[date(3i)]
Is this possible with other fields?
Cheers
I do not believe it is possible to cajole the date_select/select_date family into doing what you want.
You could try to mirror the DateTimeSelector class for your purposes: https://github.com/rails/rails/blob/master/actionpack/lib/action_view/helpers/date_helper.rb
But why not just deal with this in the controller? You can slice and dice the input any way you want. If it's a one-time thing, I would do it that way. Otherwise, it might be worth your time to solve the problem in general, in which case you can make a gem for the world to use... although I think these 'i' suffixes are only useful for dates and times as far as ActiveRecord is concerned.

Resources